We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Sum Game

Remember you can use in-place operators to increase or decrease a variable by any amount.

number_of_enemies = 10
number_of_enemies += 2
# number_of_enemies is 12
number_of_enemies = 10
number_of_enemies -= 2
# number_of_enemies is 8

Assignment

Fix the bug in the sum_of_numbers function. Instead of adding 1 to total at each iteration of the loop, it should add i. For example, instead of:

1 + 1 + 1 + 1 + 1...

we want:

0 + 1 + 2 + 3 + 4...

The desired output is a single number after the loop has finished executing.