0

What is "x" and "y" in the code below?

k = list(map(lambda x, y:x+y, list(range(100)), list(range(12)))) print (len(k))

24th Jan 2020, 3:19 AM
Shamil Erkenov
Shamil Erkenov - avatar
2 Réponses
+ 2
here is the definition of 'map' function https://docs.python.org/3/library/functions.html#map which says With multiple iterables, the iterator stops when the shortest iterable is exhausted. So, x will be 0,1,...,11 from 'list(range(100))', and y will be 0,1,...,11 from 'list(range(12))'.
24th Jan 2020, 3:40 AM
o.gak
o.gak - avatar
0
Wow, thanks ♥️
24th Jan 2020, 3:53 AM
Shamil Erkenov
Shamil Erkenov - avatar