The goal of this exercise is to write a function that adds all of the numbers up to a given number.
Value of n: 4
>>> 10 # 1 + 2 + 3 + 4 = 10
Value of n: 3
>>> 6 # 1 + 2 + 3 = 6
- Use a loop that repeats
n
times - Use a counter and add its value to the total each time
- return the total
- Test your function with the print statement provided
- If desired, modify the code in 'main' to allow the user to input a number.
- Test with pytest