while simply asks “is the condition true?” In the case of
count in range(10) it will be true for ever and ever if you have already set count to an int between 0 and 9, inclusive, and have done nothing to change it.
for-in, on the other hand, does so much more
It looks at the sequence on the right of in,
and turns it into an iterator - something that will tick on down the line every time you look at it with the keyword next, that is, if it isnt an iterator already, as range() actually is,
and then, “under the hood,” provides that next each time around,
and then assigns that next value to the iteration variable (count, in this case) you have put before in,
and knows when to stop when the iterator is empty .
All the while, it ignores any tampering you might be trying to do with your iteration variable, such as
count += 1, or
count += 100.