0
How do u rewrite this code without a boolean loop(while True)?There should still be a loop but not a boolen one
4 ответов
+ 1
Manav Roy yes instead of while True i want to use while ’something’
+ 1
ravilnicki Thats what i’m looking for, instead of while True i want while ’something’
+ 1
You can define a variable (i)
i = 0
And iterate it with a while loop.
while i < 10 :
i+=1
This code runs 10 times, If you want it to be infinite, Remove the i+=1.
What does i+=1 do?
A while loop runs as long as the condition (i is less than 10) is True. So if we add 1 to i every single time it runs, i will reach 10 after 10 executions and the condition becomes False.
0
ravilnicki while True/False has only two results, thats why i called them boolean. What i meant is to write the same code without a while True loop.