+ 1
Can someone explain why this is happening?
a = [1.2, 3.4, 10.3] b = [2.1, 2.2, 11.4] c = map(min, a, b) print(c) # returns a map generator print(list(c))# returns a list with mins of a and b for i in c: print(i) # doesn't print anything... but if I comment line 5, printing i from line 7 goes just well...
2 Answers
+ 10
A generator generates output only once. After print(list(c)), the generator is "empty" and you need to re-generate the content to use it again. If you put another c = map(min, a, b) before the for loop, it will work as expected.
+ 3
Thanks Anna!



