2016-03-04 64 views
-1
print("What is your name?") 
Name = input().title() 
Class = str(input ("What class are you in? ")) 
while Class != "1" and Class != "2" and Class != "3": 

我想python說沒有名字已經通過檢查輸入的東西被提出。蟒蛇沒有驗證我的變量

+1

是什麼問題列表? – The6thSense

+0

'而不是Class:Class = input(「再試一次:」)' – zondo

+0

''而應該在頂部而不是底部。其餘部分必須縮進。 – Selcuk

回答

1

使用的選項

options = ['1', '2', '3'] 

while True: 
    Class = input('Please enter your class') 
    if Class not in options: 
     # try again 
     continue 
    else: 
     break