While loop

Lesson

count = 0

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

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

Why does the second code cause an inifinite loop and the count variable is not incremented?

Thanks for the explanation.

the count variable is increased to 1, then in the next iteration of the loop you re-assign count a value of zero.

Each iteration of the loop, count gets “resetted” to zero

True, didn’t see that.

Thanks!