Here is the code
def func(x):
print(x)
return x
for x in (func(i) for i in range(2)):
print(x)
print('-'*20)
for x in [func(i) for i in range(2)]:
print(x)
This is the output
0
0
1
1
--------------------
0
1
0
1
Why do they have the different result? i.e, what does python do about (i for i in range(2)) and [i for i in range(2)]