Skip to content

Instantly share code, notes, and snippets.

@johnpena
Forked from garrettdreyfus/yesOrNo.py
Last active January 20, 2021 14:15
Show Gist options
  • Save johnpena/1f5b8849a77b5d35b6ce5b3432ceb28e to your computer and use it in GitHub Desktop.
Save johnpena/1f5b8849a77b5d35b6ce5b3432ceb28e to your computer and use it in GitHub Desktop.
Dead simple python function for getting a yes or no answer.
def yes_or_no(question):
reply = str(raw_input(question+' (y/n): ')).lower().strip()
if reply[0] == 'y':
return True
if reply[0] == 'n':
return False
else:
return yes_or_no("Please enter y or n: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment