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
AllAwesome497 (354)

you could also make it so x!=1

KianAlford (7)

@AllAwesome497 no. I'm wondering how to break 2 while loops. like at the end. I need to break 3 while loops on that if statement. only if that happens

VuDo (3)

@KianAlford like others had suggested, break at different loops. You could use controlled variables. e.g. isAlive = true

while isAlive

  • while isAlive and doSomething
    #to break, set isAlive = false then use break statement
    #if necessary, use if !isAlive: break immediately after the while loop if you
    #to prevent codes not inside the loop from running
KianAlford (7)

@VuDo i will try this thx

KianAlford (7)

@VuDo that would logically make no sense tho. because it only needs to tell if true or false inside that if statement. nowhere else.