+ 1
Whats the forever loop code in Python?
6 Antworten
+ 2
Yes something like that. You should put it in the begining of part of code, that must be executed infinitely. If you have function definition in your code - they probably should stay out of the loop, or they'll be redefined on each iteration.
+ 1
I believe there is a small misprint in previous example: it must have 'while' instead of 'if'.
To put it simply: infinite or forever loop is a loop, where condition always stay True. All code in this type of loop will be executed over and over again, unless it will be broken manually or some error will be raised.
0
if True:
print(1)
that's an example
0
ok. thats a good one.I'm guessing that only goes for whatever the number I put between the parentheses right?
0
ok so do I put it at the beginning of all my code?
0
it goes for whatever code you put under the if block