

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Loops
incomplete
2: Loops Practice
incomplete
3: Loops Practice
incomplete
4: Loop Review
incomplete
5: Loop Review
incomplete
6: Whitespace in Python
incomplete
7: Range Continued
incomplete
8: Sum Game
incomplete
9: Sum Game 2
incomplete
10: While
incomplete
11: Continue Statement
incomplete
12: Break Statement
incomplete
13: Match Countdown
incomplete
14: Experience Points
incomplete
15: Meditate
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The range() function we've been using in our for loops actually has an optional 3rd parameter: the "step."
for i in range(0, 10, 2):
print(i)
# prints:
# 0
# 2
# 4
# 6
# 8
The "step" parameter determines how much to add to i in each iteration of the loop. You can even go backwards:
for i in range(3, 0, -1):
print(i)
# prints:
# 3
# 2
# 1
Fix the for loop in the count_down function. It takes start and end inputs, but start is always greater than end. It's supposed to print every integer counting down by 1, beginning at start (inclusive) and stopping just before end (exclusive), but there's a mistake in the range function call.
In the programming world, it's common for the first number in a range to be inclusive and the second number is exclusive. e.g. range(0, 10) will include:
0 1 2 3 4 5 6 7 8 9