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
  • 758
  • 10
  • 22
jussi
  • 23
  • 3

2 Answers2

2

simple solution is as follows

num1 = int(input("How many laps?: "))
print(sum(range(num1)))
InAFlash
  • 4,545
  • 7
  • 32
  • 53
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
  • 112
  • 8