Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a5120e

Browse files
committed
Issue #23116: Improve ask_ok() example in the Python tutorial
1 parent e26da7c commit 0a5120e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Doc/tutorial/controlflow.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ The most useful form is to specify a default value for one or more arguments.
361361
This creates a function that can be called with fewer arguments than it is
362362
defined to allow. For example::
363363

364-
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
364+
def ask_ok(prompt, retries=4, reminder='Please try again!'):
365365
while True:
366366
ok = input(prompt)
367367
if ok in ('y', 'ye', 'yes'):
@@ -370,8 +370,8 @@ defined to allow. For example::
370370
return False
371371
retries = retries - 1
372372
if retries < 0:
373-
raise OSError('uncooperative user')
374-
print(complaint)
373+
raise ValueError('invalid user response')
374+
print(reminder)
375375

376376
This function can be called in several ways:
377377

0 commit comments

Comments
 (0)