Issue
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))
Solution
simple solution is as follows
num1 = int(input("How many laps?: "))
print(sum(range(num1)))
Answered By - rawwar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.