I have this generator that yields lists:
def gen():
state = [None]
for i in range(5):
state[0] = i
yield state
And here's the output, when I call it:
>>> list(gen())
[[4], [4], [4], [4], [4]]
Why are all the elements [4]
? Shouldn't it be [[0], [1], [2], [3], [4]]
?