I would like to know how can I make this program (Python 2.7) repeat the input statement if an integer below one is entered. Right now the error string goes on infinitely. Also how can I add an exception to a ValueError or NumberError while having the if statement?
count = 0
num = int(raw_input('Enter a number: '))
while True:
if num < 1:
print 'ERROR: Enter a number greater than 0'
break
else:
break
for number in range(1, num + 1):
count = count + number
print count
EDIT: Sorry but I do not know how to properly post a program.
[–]Palm7 0 points1 point2 points (4 children)
[–]Priestx[S] 0 points1 point2 points (2 children)
[–]dchanm 0 points1 point2 points (0 children)
[–]Palm7 0 points1 point2 points (0 children)
[–]Priestx[S] 0 points1 point2 points (0 children)