[Tutor] Python help
Shannon Evans
shannonev101 at googlemail.com
Mon Apr 2 18:44:39 EDT 2018
Hi, I am trying to write a code with if statements but the code keeps just
repeating and not carrying on.
I am trying to get user to input a grade, either A, B, C, D, E or F and
trying to have an error message if anything but these values are inputted.
This is what i've wrote so far:
while True:
try:
Grade = int(raw_input("Please enter your Grade: "))
except ValueError:
print("Error, Please enter A, B, C, D, E or F")
continue
if Grade <> 'A','B','C','D','E','F':
print ("Error, Please enter A, B, C, D, E or F")
continue
else:#Grade succesfully completed, and we're happy with its value.
#ready to exit the loop.
break
When trying to run it just writes the error message for any letter you
input.
Any hep would be appreciated thank you!
More information about the Tutor
mailing list