m = ['a', 'b', 'c', 'd']
n = list(range(1,5))
l = zip(m,n)
x = list(l)
print(x)
print(list(l))
The second print
is an empty list. Why?
Why not get the same output as the first print
?
m = ['a', 'b', 'c', 'd']
n = list(range(1,5))
l = zip(m,n)
x = list(l)
print(x)
print(list(l))
The second print
is an empty list. Why?
Why not get the same output as the first print
?
Zip returns an iterator. Once you consume the iterator then it will continue to return empty.
If you consume the iterator with list(), then you’ll see an empty list as well.