๐Ÿ PyQuest๐Ÿ” Loops Loops Loops ยท โณ Counting Up and Down
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Counting Up and Down โณ

range() can take more than one number, and that's when it gets powerful.

Two numbers = start and stop:

for i in range(1, 6):
    print(i)          # โžœ 1 2 3 4 5

It starts at 1 and stops just before 6. Python always stops before the second number โ€” a bit rude, but you get used to it.

Three numbers = start, stop, and step:

for i in range(10, 0, -1):
    print(i)          # โžœ 10 9 8 7 6 5 4 3 2 1

That -1 is the step โ€” instead of going up by one, it goes down by one. Start at 10, stop just before 0, subtract 1 each turn. Countdown! ๐Ÿš€

Your mission

  1. Use a loop to print the numbers 1 to 10, going up
  2. Use a second loop to count back down from 10 to 1
  3. After the countdown, print a big celebration message

Your code

Press โ–ถ Run to see what your code does!