help needed please...🤔 | Sololearn: Learn to code for FREE!


help needed please...🤔

Whenever i run this program it says something about the break statement not being in the loop or something. Can u pls tell me what im doing wrong? Thanks a lot. Edit: Code is while True: a=0 print (a) if (a==a): print (a+12) if a==144: break

7/2/2017 9:09:27 PM


6 Answers

New Answer


Could you please show the code so we could help?


Exactly, @Aisinthalor is right. You have to structure your loop - indent the code properly to make it a logical block. Only then the "break" will work.


Oops sorry lol it's while True: a=0 print (a) if (a==a): print (a+12) if a==144: break @kuba


first: your code will run forever, since a will be 0 for all time, and second: the break statement is not inside the loop (at least it looks like it here) you have to indent everything in your loop


Ok thanks a lot


so it's just: while True: a=0 print (a) print (a+12) (since a can't be something else than a 😉) if a==144: break a += 12 (or a = a +12 alternatively, to be sure that your loop terminates at the point you want it to)