我是这个网站的新手,这是我的第一篇文章。通常只需输入我需要的内容就可以找到答案,但为此我不知道如何用词来回答这个问题。试着把它修好,已经有一个小时了,但不知道出了什么问题。在
我的代码在下面,当我运行它时,它会打印出我拥有的函数(npc和story)以及这些函数的正确打印语句,然后停在底部,我有一个无限的while循环,什么也不做,它甚至没有注意到if语句(带有打印“storyStory”)在那里。在
我的代码是:
while True:
print "\n You wake up in a small room, the lights are dim and the only thing you can see is a table with a few gold pieces and a glass of water."
input1 = raw_input ("What do you do?").lower()
if input1 == "take gold":
print "\n You take the gold and it's added to your inventory"
time.sleep(3)
npc("jenkins_gold")
story("part1")
loop == 2
break
if input1 == "drink water":
print "\n You reach for the water, and gulp it down."
time.sleep(3)
npc("jenkins_water")
story("part1")
loop == 2
break
if loop == 2:
print "\n Story"
print "\n STORYSTORYSTORY"
while True:
y = 1
x = y
time.sleep(1)
我把整个游戏循环进行。在底部有while循环,以防与之有关。如果你需要我的代码,请告诉我,我会在几分钟内回复。谢谢你
您试图通过相等运算符
==
将2赋给loop
。相反,请使用赋值运算符=
将其赋值,如下所示:在您的第一个}(这是一个布尔表达式,因为您使用了},因此需要执行
while
语句中:loop == 2
的计算结果是{==
),并且不做其他任何操作,您希望用2
影响{loop = 2
(这将是一个赋值,因为您将使用=
)。在相关问题 更多 >
编程相关推荐