When you do something like this:
for i in range(5):
print i
What does Python do? Does it first generate an array with [0,1,2,3,4] and then iterate over each element printing it? Similar to:
for i in [0,1,2,3,4]:
print i
Or does it print each number as it is created? Sort of:
Generate 0 assign 0 for i print i
Create 1 -> assign 1 to i -> print i
Create 2 -> Assign 2 to me -> print i
Create 3 -> Assign 3 to me -> print i
Generate 4 -> assign 4 to i -> print i
Update
I added a tag for Python 2.7. I did not think that my question is about the version, but it seems to be so!
I am working with Python 2.7 now, so my question relates to this. But I find the information comparing the Python 2 range to the Python 3 range very valuable.