def ask_ok(prompt, retries=4, complaint="Yes or no, please!"): while True: password = input("enter something") if password in ('y', 'ye', 'yes'): return True if password in ('n', 'no', 'nope'): return False retries = retries - 1 if retries < 0: raise IOError('refusenik user') print(complaint)
-- http://mail.python.org/mailman/listinfo/python-list