Skip to content

Instantly share code, notes, and snippets.

@math2001
Created February 9, 2017 08:10
Show Gist options
  • Save math2001/4846ab8c233b402d0613057fbe85d13d to your computer and use it in GitHub Desktop.
Save math2001/4846ab8c233b402d0613057fbe85d13d to your computer and use it in GitHub Desktop.
def confirm(question):
YES, NO = ['yes', 'y'], ['no', 'n']
ans = ''
while ans not in YES + NO:
ans = input(question + ' (y/n) ').strip().lower()
if ans in YES:
return True
elif ans in NO:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment