Loops · warm-up
Add up to n
Write sum_to(n) that returns 1 + 2 + … + n using a loop. sum_to(4) is 10, and sum_to(0) is 0.
- right answers
- arguments left as they should be
- without sum
Run adds print(sum_to(4)) after your code, to try it.
Stuck on the idea rather than the code? The Doing it again lesson walks through it.