My teacher wants a program to ask the user for a positive integer number value, which the program should loop to get the sum of all integers from 1 up to the numbered entered. In For Loop using Python.
Here's what I came up with for the For Loop but it is not's not looping when I type in a negative number and it won't display an answer when I input a positive number after inputting a negative number.
x=int(input("Please pick a positive integer"))
sum=0
for i in range(1,x):
sum=sum+1
print(sum)
else:
x=int(input("Please pick a positive integer"))
Help?
sum(range(x+1))where x is your positive integer value. - Andrew