-3
你好我做了這個程序,要求用戶輸入的選擇打印,SORT1,SORT2或退出爲什麼我的程序打印該字符串時,我有一段時間!=字符串
usrinpt=0
while usrinpt != "quit": #if usrinpt == quit then no if statements right?
usrinpt = input("Enter choice Print, Sort1 (distance), Sort2 (price) or Quit : ")
usrinpt = usrinpt.lower()
if usrinpt == "print":
PrintList(mat)
pass
elif usrinpt == "sort1":
SelectionSortDistorPrice(mat,0)
PrintList(mat)
pass
elif usrinpt == "sort2":
SelectionSortDistorPrice(mat, 1)
PrintList(mat)
pass
elif usrinpt != "quit"or"sort1"or"sort2": #why does it print the string even when i enter quit?
print("please enter a valid choice")
pass
- 預期結果對於選擇「跳槽」是一個程序停止
- 實際的結果是,程序打印「請輸入一個有效的選擇」,然後退出
我怎樣才能修復它只能打印字符串如果選擇不是狀態d是否進入?
請修復您的縮進。 – blacksite
哪裏不合適? nvm我看到了 –