Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Post Timeline

deleted 8 characters in body
Source Link
DirtyBit
  • 16.8k
  • 5
  • 37
  • 56

You don't need multiple while loops but a simple if-elif inside the loop:

n = input("You are in the Lost Forest\n****************\n****************\n :)\n****************\n****************\nGo left or right? ")
i = 1
while (n.lower() == "right" or n == "Right"):
 if i < 3:
 n = input("You are in the Lost Forest\n****************\n****************\n :(\n****************\n****************\nGo left or right? ")
 elif i >= 3:
 n = input("You are in the Lost Forest\n****************\n****** ***\n (╯°しろいしかく°)╯( ┻━┻\n****************\n****************\nGo left or right? ")
 i = i + 1

You don't need multiple while loops but a simple if-elif inside the loop:

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"):
 if i < 3:
 n = input("You are in the Lost Forest\n****************\n****************\n :(\n****************\n****************\nGo left or right? ")
 elif i >= 3:
 n = input("You are in the Lost Forest\n****************\n****** ***\n (╯°しろいしかく°)╯( ┻━┻\n****************\n****************\nGo left or right? ")
 i = i + 1

You don't need multiple while loops but a simple if-elif inside the loop:

n = input("You are in the Lost Forest\n****************\n****************\n :)\n****************\n****************\nGo left or right? ")
i = 1
while (n.lower() == "right"):
 if i < 3:
 n = input("You are in the Lost Forest\n****************\n****************\n :(\n****************\n****************\nGo left or right? ")
 elif i >= 3:
 n = input("You are in the Lost Forest\n****************\n****** ***\n (╯°しろいしかく°)╯( ┻━┻\n****************\n****************\nGo left or right? ")
 i = i + 1
Source Link
DirtyBit
  • 16.8k
  • 5
  • 37
  • 56

You don't need multiple while loops but a simple if-elif inside the loop:

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"):
 if i < 3:
 n = input("You are in the Lost Forest\n****************\n****************\n :(\n****************\n****************\nGo left or right? ")
 elif i >= 3:
 n = input("You are in the Lost Forest\n****************\n****** ***\n (╯°しろいしかく°)╯( ┻━┻\n****************\n****************\nGo left or right? ")
 i = i + 1
lang-py

AltStyle によって変換されたページ (->オリジナル) /