你好,我做了这个程序,要求用户输入选择打印,排序1,排序2或退出
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
如果输入了一个未声明的选项,如何将其修改为只打印该字符串?你知道吗
elif usrinpt not in ["quit","sort1","sort2"]:
相关问题 更多 >
编程相关推荐