classification
Title: Revise example of "continue" in the tutorial documentation
Type: performance Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: amirrossein, docs@python, eric.smith, miss-islington, neerajsamtani
Priority: normal Keywords: easy, newcomer friendly, patch

Created on 2020-09-13 11:59 by amirrossein, last changed 2020-09-15 13:58 by eric.smith. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22234 merged neerajsamtani, 2020-09-13 23:15
PR 22255 merged miss-islington, 2020-09-15 13:39
PR 22256 merged miss-islington, 2020-09-15 13:40
Messages (5)
msg376834 - (view) Author: Amir Sadegh (amirrossein) Date: 2020-09-13 11:59
It's not wrong but in the example for "continue" in the tutorial, the code prints "Found an even number" for even numbers and "Found a number" for odd numbers. Maybe it would be better if we print "Found an odd number" for odd numbers. Like this:

for num in range(2, 10):
    if num % 2 == 0:
        print("Found an even number", num)
        continue
    print("Found an odd number", num)

Found an even number 2
Found an odd number 3
Found an even number 4
Found an odd number 5
Found an even number 6
Found an odd number 7
Found an even number 8
Found an odd number 9
msg376857 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-13 21:07
I think that's a good change. It makes it clear when reading the source that the print statement at the end of the loop is only executed for odd numbers.

Sure, you know this if you execute the code, or if you know how python for loops and continue work. But since this is a tutorial, I think being more explicit is clearer.
msg376937 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-15 13:39
New changeset 7bcc6456ad4704da9b287c8045768fa53961adc5 by Neeraj Samtani in branch 'master':
bpo-41776: Revise example of "continue" in the tutorial documentation (GH-22234)
https://github.com/python/cpython/commit/7bcc6456ad4704da9b287c8045768fa53961adc5
msg376938 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-15 13:56
New changeset 0cc037f8a72c283bf64d1968e34cbdc22b0e3010 by Miss Islington (bot) in branch '3.9':
bpo-41776: Revise example of "continue" in the tutorial documentation (GH-22234) (GH-22255)
https://github.com/python/cpython/commit/0cc037f8a72c283bf64d1968e34cbdc22b0e3010
msg376939 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-09-15 13:56
New changeset a0da90720d5330c53b8083272374ede1c7a1e33a by Miss Islington (bot) in branch '3.8':
bpo-41776: Revise example of "continue" in the tutorial documentation (GH-22234) (GH-22256)
https://github.com/python/cpython/commit/a0da90720d5330c53b8083272374ede1c7a1e33a
History
Date User Action Args
2020-09-15 13:58:13eric.smithsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-09-15 13:56:46eric.smithsetmessages: + msg376939
2020-09-15 13:56:37eric.smithsetmessages: + msg376938
2020-09-15 13:40:03miss-islingtonsetpull_requests: + pull_request21311
2020-09-15 13:39:55miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request21310
2020-09-15 13:39:48eric.smithsetmessages: + msg376937
2020-09-13 23:15:38neerajsamtanisetkeywords: + patch
nosy: + neerajsamtani

pull_requests: + pull_request21288
stage: patch review
2020-09-13 21:07:17eric.smithsetkeywords: + easy, newcomer friendly
nosy: + eric.smith
messages: + msg376857

2020-09-13 11:59:02amirrosseincreate