The outcome is None
with list(a)
the second time. Anyone have a clue on that?
>>> test = {1: 2, 3: 4}
>>> a= test.iterkeys()
>>> list(a)
**[1, 3]**
>>> list(a)
**[]**
>>> list(a)
[]
The outcome is None
with list(a)
the second time. Anyone have a clue on that?
>>> test = {1: 2, 3: 4}
>>> a= test.iterkeys()
>>> list(a)
**[1, 3]**
>>> list(a)
**[]**
>>> list(a)
[]
iterkeys
returns an iterator, which, as any iterator, can be iterated over only once.
list
consumes the whole iterator, so that the latter can't provide any more values, so the subsequent lists are empty.