Why is this while loop not ending when the proper input is entered (a number between 0 and 100)
grade = 110
invalid_input = 1
while grade< 0 or grade> 100:
if invalid_input >=2:
print "This is an invalid entry"
print "Please enter a number between 0 and 100"
grade= raw_input("Please enter your marks for Maths : ")
invalid_input +=1
what ever i put in be it a number or text the (this is an invalid entry , Please enter a number between 0 and 100
does anyone one know what is wrong?
in
grade=raw_input("Please enter your marks for Maths : "),gradeis a string, not number. tryIn order to prevent the program from being terminated if the user makes a wrong input, you will need to use a exceptions, like this