def get_pokemon_type(pokemon_types):
    """Asks the user for a type of pokemon and displays the names of all
    pokemon with that type.

    Implicitly converts the type entered by the user to lower case.

    If the user enters an invalid type, warns the user and repeats until they
    enter a valid one.

    Args:
        pokemon_types: a list of pokemon types sorted in alphabetic order

    Returns:
        the pokemon type chosen by the user
    """
    # This is the prompt you'll display to the user to ask for their choice.
    # Don't modify it!
    prompt = ('enter a type from one of the following: \n{0}\n'.format(
        ', '.join(pokemon_types)))
    # This is the prompt you'll display to the user if they enter something
    # invalid. Don't modify it!
    warning = 'Unrecognized type'


    choice = input(prompt)
    choice = choice.lower()
    condition = True

    while condition:
        if choice in pokemon_types:
            condition = False
        else:
            print(warning)
            choice = input(prompt)
            choice = choice.lower()

    return choice