Pack 1 · Challenge 2 of 5 · 10 XP · ⏱ 4 min
Even Steven
2️⃣ % gives the remainder after dividing. Even numbers have no remainder when you divide by 2, so n % 2 == 0 is True for them.
print(7 % 2) print(8 % 2)
1 0
You can also step through range() two at a time. Either way works.
Instructions
- Use a
forloop (don't type the numbers by hand). - Print every even number from 2 to 20, one per line.
💡 Hint
for n in range(1, 21): then if n % 2 == 0: print(n). Or step two at a time with range(2, 21, 2).
bot.py
Terminal