Python is built using the function map

In fact, the feeling of map and filter function is very similar, we are processing sequence, process sequence.

 
 
"" " 
The Map () function will do according to the specified sequence provided maps. 
The first parameter to the function parameters of each element in the sequence function call function, every function returns a new list of function return values. " 
""

DEF
the Add (X): return X +. 1 mylist = List (Map (the Add, [1,2,3,4,5,6 ])) Print (mylist) >> [2,. 3,. 4,. 5,. 6, 7] # two lists, a list of data of the same position are summed mylists = list (Map ( the lambda X, Y: X + Y, [. 1,. 3,. 5, 7,. 9], [2,. 4, . 6,. 8, 10 ])) Print (mylists) >> [. 3,. 7,. 11, 15,. 19]


 

Guess you like

Origin www.cnblogs.com/wxzbk/p/10985691.html