擅长:python、mysql、java
<p>您的if条件没有按预期工作,因为条件是按顺序计算的。因此,如果<code>n=="right"</code>为真,<code>i</code>的值无关紧要。相反,您应该将其更改为:</p>
<pre><code>n = input("You are in the Lost Forest\n****************\n****************\n :)\n****************\n****************\nGo left or right? ")
i = 1
while (n == "right" or n == "Right") and i < 3:
n = input("You are in the Lost Forest\n****************\n****************\n :(\n****************\n****************\nGo left or right? ")
i = i + 1
while (n == "right" or n == "Right") and i >= 3:
n = input("You are in the Lost Forest\n****************\n****** ***\n (╯°□°)╯︵ ┻━┻\n****************\n****************\nGo left or right? ")
print("\nYou got out of the Lost Forest!\n\o/")
</code></pre>