โ ๐ Python World
๐ Even Steven
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
Loops inspect each item
Many levels use a loop: start with a simple value, visit each item, update the answer, then return it at the end.
๐ก Hint ladder
- Loop and check n % 2 == 0 before adding.
- Fancy version: sum(n for n in numbers if n % 2 == 0)
๐งช Coach checks
- โฏ evens of 1-4
- โฏ no evens
- โฏ all evens
- โฏ empty list
Live coach
Getting ready
โโโ
๐ฌ A loop plus an if โ only add the numbers that pass the test.
def sum_big_numbers(numbers):
total = 0
for n in numbers:
if n > 100:
total = total + n
return total
print(sum_big_numbers([50, 200, 999])) # 1199
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?