如何进行连续输入?我希望玩家能够在他想要的任何时候编写菜单,而不仅仅是在程序开始时?
print("\nWelcome to the nature center. What would you like to do?")
choice = ''
while choice != 'q':
print("\n[1] Enter 1 to take a bicycle ride.")
print("[2] Enter 2 to go for a run.")
print("[3] Enter 3 to climb a mountain.")
print("[q] Enter q to quit.")
choice = input("\nWhat would you like to do? ")
if choice == '1':
print("\nHere's a bicycle. Have fun!\n")
elif choice == '2':
print("\nHere are some running shoes. Run fast!\n")
elif choice == '3':
print("\nHere's a map. Can you leave a trip plan for us?\n")
elif choice == 'q':
print("\nThanks for playing. See you later.\n")
else:
print("\nI don't understand that choice, please try again.\n")
郎朗坤
慕田峪7331174
相关分类