Created
March 15, 2019 00:59
-
-
Save GenevieveBuckley/ecd40c3e3862f1b59d23c029fc36f6ae to your computer and use it in GitHub Desktop.
User input in python using a while loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': ") | |
print(user_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment