Aby Anil
Aby Anil

Reputation: 1

Having trouble with Validation

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")

Upvotes: 0

Views: 25

Answers (1)

Vishnu
Vishnu

Reputation: 324

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"

Upvotes: 1

Related Questions