Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
User input in python using a while loop
response_yes = ['yes', 'y']
response_no = ['no', 'n']
response_cancel = ['quit', 'q', 'exit', 'cancel']
known_responses = response_yes + response_no + response_cancel
user_response = ''
while user_response.lower() not in known_responses:
user_response = input("Please input a value, or enter 'quit': ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.