Answers for "how to give multiple option to the user and ask the same question again and again until the user tells one of the options"

1

how to give multiple option to the user and ask the same question again and again until the user tells one of the options

while True:
    data = input("Please enter a loud message (must be all caps): ")
    if not data.isupper():
        print("Sorry, your response was not loud enough.")
        continue
    else:
        #we're happy with the value given.
        #we're ready to exit the loop.
        break

while True:
    data = input("Pick an answer from A to D:")
    if data.lower() not in ('a', 'b', 'c', 'd'):
        print("Not an appropriate choice.")
    else:
        break
Posted by: Guest on January-29-2021

Code answers related to "how to give multiple option to the user and ask the same question again and again until the user tells one of the options"

Python Answers by Framework

Browse Popular Code Answers by Language