diff options
author | Antoine <43954001+awecx@users.noreply.github.com> | 2020-05-23 00:29:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-23 00:29:34 (GMT) |
commit | 6fad3e6b49f6a9f8b8a6635c41371e4451479f86 (patch) | |
tree | b14fe05d15e12360b960441c433865d3b166956d /Doc | |
parent | b5cc2089cc354469f12eabc7ba54280e85fdd6dc (diff) | |
download | cpython-6fad3e6b49f6a9f8b8a6635c41371e4451479f86.zip cpython-6fad3e6b49f6a9f8b8a6635c41371e4451479f86.tar.gz cpython-6fad3e6b49f6a9f8b8a6635c41371e4451479f86.tar.bz2 |
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>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tutorial/controlflow.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index f05f5ed..26de866 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -70,6 +70,9 @@ Code that modifies a collection while iterating over that same collection can be tricky to get right. Instead, it is usually more straight-forward to loop over a copy of the collection or to create a new collection:: + # Create a sample collection + users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'} + # Strategy: Iterate over a copy for user, status in users.copy().items(): if status == 'inactive': |