August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 22 | Loop de Loop |
| | for n in range(5): |
| | print(n, end=' ') |
| | n = 5 |
| | print() |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: 0 1 2 3 4
Python’s for loop is a “for each.” Iteration in Python involves two types:
The object we’re iterating over (e.g., str, list, dict …)
Does the actual iteration; can only fetch the next item and signal it’s done (i.e., exhausted) ...
Read now
Unlock full access