batchfile的GOTO命令的Python版本?

2024-04-25 20:28:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我到处找了,想找到这个问题的答案,但似乎找不到。我从Python开始,我试图做一个简单的测验游戏。我希望播放器能够键入他们想要的菜单名goto。你知道吗

到目前为止我有:

print("Hello, and welcome to the Python Quiz.")
print("[START]")
print("[HELP]")
print("[ABOUT]")
print("[EXIT]")
menu = input("Type name of menu to navigate to corresponding menu. ")

if menu == "START":
    ...........

接下来是什么?你知道吗


Tags: andtheto答案游戏hello键入菜单
1条回答
网友
1楼 · 发布于 2024-04-25 20:28:55

我会将每个菜单定义为它应该打印的样子

def help():
  print(option1)
  print(option2)
  print(option3)

然后你就可以做一些

if menu == "HELP":
  help()
elif menu == "START":
  start()

相关问题 更多 >