0

[SOLVED] I'm learning while loop, and can someone tell me why the "break" statement isn't stoping the loop here?

https://code.sololearn.com/cev383pun3Nv/?ref=app

1st Jan 2021, 2:41 PM
Albanianz
Albanianz - avatar
3 Respuestas
+ 3
Line 8: Use if instead of while x = 1 while x>=1: print(x) x = x + 1 if x == 5: print("breaking") break
1st Jan 2021, 2:44 PM
Vadivelan
+ 3
Albanianz It's a inner loop break. So it will only break the inner loop not outer loop. You have to use if statement as Vadivelan said.
1st Jan 2021, 2:45 PM
A͢J
A͢J - avatar
0
Vadivelan thanks, I tried if a bit but got some errors so I thought I wasn't doing it wrong but it's doesn't work that way
1st Jan 2021, 2:49 PM
Albanianz
Albanianz - avatar