Break - question


I don’t undertstand how this is an infinite loop.

If count = 0, then the count is printed and incremented.
But then, count is not 0 anymore, so the while should stop… right?
Why does it continue until infinity, or in this case, the break? Can anyone explain?


count = 0

while True:
  print count
  count += 1
  if count >= 10:


it isn’t, the loop ends thanks to break, so its not an infinity loop

no, while is still evaluating to true thanks to True boolean value at the loop condition. Look at the loop condition:

while True

there is no comparison with zero, so why should the loop stop when count is no longer zero?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.