I want to validate that the class is a number between 1 and 6. Any help would be greatly appreciated.
print("What is your name?") #Asking User Name
name = input().title()
class_name = input("What class are you in? ")
print (name, ", Welcome to the Maths Test")
-
Duplicate: stackoverflow.com/questions/13628791/…Jack– Jack2016年02月25日 10:53:56 +00:00Commented Feb 25, 2016 at 10:53
1 Answer 1
You can try by using an if condition which checks the value your entered is between 1 and 6:-
if not int(class_name, 16)>1 and int(class_name, 16) < 6:
print "Your validation message"
answered Feb 25, 2016 at 10:47
Vishnu
3241 gold badge3 silver badges18 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py