print(" You can see a faint outline of a coast in the distance... you can either: 1. paddle to the island on the raft ; 2. swim to the island")
option2 = input("> ")
while True:
if (option2 == "1"):
print("The raft fully sinks... you are left in the freezing cold water. You spent all your energy trying to keep the raft afloat. You have made your demise inevitable")
break
elif (option2 == "2"):
print("You jump headfirst into the cold water... not really a good idea, but you seem to have insane swimming skills. Are you Michael Phelps? Anyways you make it to the shore seconds before fainting")
else:
print(" Invalid input: Please select one of the options above") <---- It keeps printing this
continue
This is the code that I used. I'm new to Python and I really don't know how while loops function
I 've tried finding syntax issues but I can't spot any
Now it gets looping infinitely if you enter an option that is not "1". You will get into the else statement, which contains the 'continue' keyword.
'continue' means to start the next iteration. And as far as your option is captured only once (before the loop), its never gets changed, so you will be falling into the else block always.
In order to make it work, you need to move your "option2 = input("> ")" inside of the loop and add a break for the second elif:
You can read more about how the while loops work here