Skip to content

Instantly share code, notes, and snippets.

@ralflukner
Created November 26, 2012 00:17
Show Gist options
  • Save ralflukner/4145984 to your computer and use it in GitHub Desktop.
Save ralflukner/4145984 to your computer and use it in GitHub Desktop.
ask_ok tutorial file
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while True:
ok = raw_input(prompt)
if ok in ('y', 'ye', 'yes'):
print "True"
return True
if ok in ('n', 'no', 'nop', 'nope'):
print "False"
return False
retries = retries - 1
if retries < 0:
raise IOError('refusenik user')
print complaint
ask_ok("yes or no?",4,"y or no")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment