+ 1

Infinite loop

is this the correct way to go on a infinite loop c = 0 while True: print(c) c+=2 if c > 500: break

27th Jul 2021, 9:16 AM
Tomoe
Tomoe - avatar
2 odpowiedzi
+ 10
No because your code will break the loop once the value of c is more than 500 remove the break statement to make it an infinite loop # a general infinite loop while True: # statements Note: You can even use the number 1 instead of True
27th Jul 2021, 9:18 AM
RKK
RKK - avatar
+ 1
Oh, i thought the 0(False) and 1(True) just based examples didn't thought they could actually be used in actual code
27th Jul 2021, 10:26 AM
Tomoe
Tomoe - avatar