你好我做了这个程序,要求用户输入选项Print,sort1,sort2或quit
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
如果输入未说明的选项,如何修复它只打印该字符串?
答案 0 :(得分:1)
elif usrinpt not in ["quit","sort1","sort2"]: