breaking while loops
KianAlford (7)

I'm currently trying to make an RP game. all I need to do is break a few while loops. but a certain amount of times every time. I can't figure out how to do it.

https://repl.it/@KianAlford/RPG-adventure-1

You are viewing a single comment. View All
PYer (3015)

In python, you can use the break statement:
for example:

while True:
   if 1 == 2: break
   print('I does not equal 2')

Please mark this as the correct answer thanks!

AllAwesome497 (354)

@PYer wait what if it isnt the right answer :thonk:

KianAlford (7)

@AllAwesome497 I need to break multiple while loops inside one if statement

AllAwesome497 (354)

@KianAlford maybe add a if statement to all of them that breaks it if a certain codition is met?:
Ex:

if dead:
    break

that may work.

KianAlford (7)

@AllAwesome497 no because of those variables before they are not defined but only once then

AllAwesome497 (354)

@KianAlford add dead=False at the beginning of it

AllAwesome497 (354)

@PYer, first of all, it wasn't, second of all, it was a joke.

PYer (3015)

@AllAwesome497 what is the answer? he/she asked on how to break out of a while loop. i showed how to

AllAwesome497 (354)

@PYer He wants to break multiple loops within 1 if statement

AllAwesome497 (354)

@PYer I already said that. Although i just did a few minutes ago so u may not have seen it. was not on the reply thread