samedi 21 novembre 2020

resetting and "if" statement

I am having trouble resetting and if statement to capture the correct input into the command:

If you select '2', if it will ask you again. If you respond 'L', it will capture that as a valid command, however the 'Letter' variable will still be stored as the original input '2'. How do I reset the first command to take the second?

# Letters is captured in a list A-Z

def choose_letter(question):
    Letter = input('choose a letter:')
    if Letter not in Letters:
        print('Please choose a valid Letter. A-Z.')
        choose_letter(question)
    else:
        return Letter

Aucun commentaire:

Enregistrer un commentaire