Commit e4c997e3 authored by Berker Peksag's avatar Berker Peksag

Issue #23116: Improve ask_ok() example in the Python tutorial

parent ffd866fe
...@@ -361,7 +361,7 @@ The most useful form is to specify a default value for one or more arguments. ...@@ -361,7 +361,7 @@ The most useful form is to specify a default value for one or more arguments.
This creates a function that can be called with fewer arguments than it is This creates a function that can be called with fewer arguments than it is
defined to allow. For example:: defined to allow. For example::
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): def ask_ok(prompt, retries=4, reminder='Please try again!'):
while True: while True:
ok = input(prompt) ok = input(prompt)
if ok in ('y', 'ye', 'yes'): if ok in ('y', 'ye', 'yes'):
...@@ -370,8 +370,8 @@ defined to allow. For example:: ...@@ -370,8 +370,8 @@ defined to allow. For example::
return False return False
retries = retries - 1 retries = retries - 1
if retries < 0: if retries < 0:
raise OSError('uncooperative user') raise ValueError('invalid user response')
print(complaint) print(reminder)
This function can be called in several ways: This function can be called in several ways:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment