验证有问题

时间:2016-02-25 10:42:43

标签: python validation

我想验证该类是1到6之间的数字。任何帮助都将非常感谢。

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

1 个答案:

答案 0 :(得分:1)

您可以尝试使用if条件检查输入的值在1到6之间: -

if not int(class_name, 16)>1 and int(class_name, 16) < 6:
    print "Your validation message"