+ 1
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
6 Respuestas
+ 7
Could you please show the code so we could help?
+ 5
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.
+ 1
Oops sorry lol it's
while True:
a=0
print (a)
if (a==a):
print (a+12)
if a==144:
break
@kuba
+ 1
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
+ 1
Ok thanks a lot
+ 1
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)