0
我想驗證該類是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到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")
您可以通過使用一個if條件,檢查值您輸入的是1和6之間嘗試: -
if not int(class_name, 16)>1 and int(class_name, 16) < 6:
print "Your validation message"
重複:http://stackoverflow.com/questions/13628791/how- DO-檢查,是否-AN-INT-是最兩個數字之間, – Jack