<p>所以问题是,在输入函数中有超过on的参数,这与print不同,是无法做到的。使用加号而不是逗号将字符串连接在一起可以很容易地解决这个问题,但是要做到这一点,您必须将int-shield转换为字符串,只需放入str(shield)来转换它。这是我编写的Python2.7,所以您可能需要更改一些内容,但应该都在那里。我还将.upper()添加到if语句中,以便它可以接受大小写输入。ps对于Python3,您将执行input(),而不是raw\u input()。对不起,我在2.7中写的我不是3的好。如果你有什么问题尽管问</p>
<pre><code>import random
from random import randint
print("Welcome to Brandon's Maze Game",
"You have to get 10 shields or find the exit to win",
"Good Luck :D")
counter = 0
shields = 3
fate = randint(1,2)
direction = raw_input("You have come to a stop, do you want to turn Left(L) or Right(R)? ")
if direction.upper() == "L":
if fate == 1:
shields += 3
counter += 1
direction = raw_input("You came across a chest, you now have "+str(shields)+ "! What way do you want to go next? Left(L) or Right(R)? ")
if fate == 2:
shields -= 1
counter += 1
direction = raw_input("Uh oh, you got attacked and lost a shield, you now have "+str(shields)+" shields. Do you want to go Left(L) or Right(R)? ")
if direction.upper() == "R":
if fate == 1:
shields += 3
counter += 1
direction = raw_input("You came across a chest, you now have "+str(shields)+"! What way do you want to go next? Left(L) or Right(R)? ")
if fate == 2:
shields -= 1
counter += 1
direction = raw_input("Uh oh, you got attacked and lost a shield, you now have "+str(shields)+" shields. Do you want to go Left(L) or Right(R)? ")
if counter == 10:
print("Congratulations, you made it to the end with "+str(shields)+" shields.")
</code></pre>