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
No active XP Potion
Accept a Quest
Login to submit answers
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 numbers counting down from start
to 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
Focus Editor
Alt+Shift+]
Become a member to Submit
Become a member to Run
Become a member to view solution