Skip to content

Instantly share code, notes, and snippets.

@GenevieveBuckley
Created March 15, 2019 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GenevieveBuckley/ecd40c3e3862f1b59d23c029fc36f6ae to your computer and use it in GitHub Desktop.
Save GenevieveBuckley/ecd40c3e3862f1b59d23c029fc36f6ae to your computer and use it in GitHub Desktop.
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': ")
print(user_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment