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")
asked Feb 25, 2016 at 10:42
1

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.