def bankcard_type(card_number):
    """
    Return the type of a bankcard based on its card_number.

    Returns None is the card_number is not recognised.
    """
    def matches(card_number, lengths, prefixes):
        if len(card_number) not in lengths:
            return False
        for prefix in prefixes:
            if card_number.startswith(prefix):
                return True
        return False
    for card_type, lengths, prefixes in CARD_TYPES:
        if matches(card_number, lengths, prefixes):
            return card_type
dataset/ETHPy150Open django-oscar/django-oscar/src/oscar/apps/payment/bankcards.py/bankcard_type/original