0

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: http://stackoverflow.com/questions/13628791/how-do-i-check-whether-an-int-is-between-the-two-numbers – Jack Feb 25 '16 at 10:53

1 Answers1

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"
Vishnu
  • 324
  • 1
  • 3
  • 17