Created
November 26, 2012 00:17
-
-
Save ralflukner/4145984 to your computer and use it in GitHub Desktop.
ask_ok tutorial file
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
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