我现在正在学习如何使用python。我在学习我不理解的定义时发现了一个问题。我给出了一个简单的菜单,选择 0-4。如果用户选择上述 4,应该会收到一条消息,上面写着“这不是一个有效的选择......”
但是,如果您输入一个大于或等于 10 的值,它不会返回任何内容,只返回菜单...没有消息。
提前感谢您的任何想法。
这是我的代码:
# Multitasker
# Allows User to Pick an Item that is Defined.
def exit():
print("See You Later!")
def task1():
print("This is Task 1!")
def task2():
print("This is Task 2!")
def task3():
print("This is Task 3!")
def task4():
print("This is Task 4!")
choice = None
while choice != "0":
print(
"""
Multitask Selector
0 - Quit
1 - Task 1
2 - Task 2
3 - Task 3
4 - Task 4
"""
)
choice = input("Pick a Task Between 1-4:\t#")
print()
# Exit
if choice == "0":
exit()
# Task 1
elif choice == "1":
task1()
# Task 2
elif choice == "2":
task2()
# Task 3
elif choice == "3":
task3()
# Task 4
elif choice == "4":
task4()
# Not a Correct Selection
elif choice > "4":
print("That is not a valid choice. Please Select a Task Between 1-4.")