Skip to content

Commit 6fad3e6

Browse files
awecxblurb-it[bot]
andauthored
bpo-40552 Add 'users' variable in code sample (tutorial 4.2). (GH-19992)
* Add 'users' variable in code sample. * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
1 parent b5cc208 commit 6fad3e6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Doc/tutorial/controlflow.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ Code that modifies a collection while iterating over that same collection can
7070
be tricky to get right. Instead, it is usually more straight-forward to loop
7171
over a copy of the collection or to create a new collection::
7272

73+
# Create a sample collection
74+
users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}
75+
7376
# Strategy: Iterate over a copy
7477
for user, status in users.copy().items():
7578
if status == 'inactive':
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix in tutorial section 4.2.
2+
Code snippet is now correct.

0 commit comments

Comments
 (0)