小编Hea*_* HA的帖子

如何使python“转到”前一行以获得更多输入?

所以我知道 goto 是一种非常糟糕的编码形式,但是当控制台中的输入不正确时,我需要一个程序来返回上一行。

print ("You wake up.")
print ("You do what?")
seg1 = input()
if seg1 == ("Stand") or seg1 == ("stand") or seg1 == ("stand up") or seg1 == ("Stand up") or seg1 == ("Stand Up"):
    print ("You get up")
    print ("You look around you... your in a dark room. A door hangs slightly ajar infront of you.")
    print ("You do what?")
else:
    print ("I dont understand")
Run Code Online (Sandbox Code Playgroud)

在 else 语句运行后,我希望它重复第 2 行并从那里继续执行程序……我该怎么做?

python if-statement goto

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

goto ×1

if-statement ×1

python ×1