1

So my problem is that this program should take inputted numbers (e.g 5) would be 0+1+2+3+4 and the sum would be 10. I have gotten it to list these numbers but how do I make this code to count them?

num1 = int(input("How many laps?: "))
num2 = int(0)

for lap in range (num1):
   num2 = lap
   print("Sum is:" , (num2))
maciejwww
  • 1,067
  • 1
  • 13
  • 26
jussi
  • 23
  • 3

2 Answers2

2

simple solution is as follows

num1 = int(input("How many laps?: "))
print(sum(range(num1)))
rawwar
  • 4,834
  • 9
  • 32
  • 57
2

Doing it with a loop like you were trying

num1 = int(input("How many laps?: "))

list = []

for lap in range (num1):
   list.append(lap)

listSum = sum(list)

print(listSum)
Rodi
  • 122
  • 8