Hello ,
I can't understand why this loop doesn't work as I wanted.
Why the continue statement isn't executed.
I want the code to count only the user input which is 1 or 2 and stop when the sum is >=25.
i = 0
user = input('Enter '1' or '2': ')
while True:
if ( user == '1' or user == '2' ):
i += int(user)
print('Sum is {0}'.format(i))
if i < 25:
continue
else:
break
else:
print('Invalid input')
user = input('Enter '1' or '2': ')
Right know if I run the program it gives:
Enter '1' or '2': 1
Sum is 1
Sum is 2
Sum is 3
Sum is 4
.....
Sum is 25