Back to questions
JuniorTheoryCommon
What does the program print?
for n in range(10):
if n % 2 == 0:
continue
if n > 6:
break
print(n, end="")135
- Expecting
1357, as ifbreaklet the current pass finish: it leaves the loop at once, so whennis7theprintbelow it never runs. - Expecting
13579, as ifbreakonly left theif: it ends the wholeforloop, so no number after7is even checked.
- What would the program print if
breakwere replaced withcontinue? - Why does the output appear on one line?