human
Can you provide a the Python code you requested given the following:
Complete the below
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.'
    '''
assistant
#Here is the Python code you requested.
    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