-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說沒有名字已經通過檢查輸入的東西被提出。蟒蛇沒有驗證我的變量
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說沒有名字已經通過檢查輸入的東西被提出。蟒蛇沒有驗證我的變量
使用的選項
options = ['1', '2', '3']
while True:
Class = input('Please enter your class')
if Class not in options:
# try again
continue
else:
break
是什麼問題列表? – The6thSense
'而不是Class:Class = input(「再試一次:」)' – zondo
''而應該在頂部而不是底部。其餘部分必須縮進。 – Selcuk