From 5170b2724d2f7040f4839c9fd73c17e561d29329 Mon Sep 17 00:00:00 2001 From: Jeremy Dolan Date: Thu, 14 Dec 2023 09:25:19 -0500 Subject: [PATCH 1/2] doc: use less ambiguously named variable --- Doc/tutorial/controlflow.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index aa9caa101da40a..5873644e0c2412 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -559,10 +559,10 @@ defined to allow. For example:: def ask_ok(prompt, retries=4, reminder='Please try again!'): while True: - ok = input(prompt) - if ok in ('y', 'ye', 'yes'): + reply = input(prompt) + if reply in ('y', 'ye', 'yes'): return True - if ok in ('n', 'no', 'nop', 'nope'): + if reply in ('n', 'no', 'nop', 'nope'): return False retries = retries - 1 if retries < 0: From 68fd5d53798436ca3bd5d7a824f85b432f99c14d Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 14 Dec 2023 09:32:25 -0600 Subject: [PATCH 2/2] Convert tuples to sets --- Doc/tutorial/controlflow.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 5873644e0c2412..77444f9cb8358d 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -560,9 +560,9 @@ defined to allow. For example:: def ask_ok(prompt, retries=4, reminder='Please try again!'): while True: reply = input(prompt) - if reply in ('y', 'ye', 'yes'): + if reply in {'y', 'ye', 'yes'}: return True - if reply in ('n', 'no', 'nop', 'nope'): + if reply in {'n', 'no', 'nop', 'nope'}: return False retries = retries - 1 if retries < 0: