Use of Map ()
Map () is used in the form of a map (f (x), Itera). Yes, it has two parameters, the first argument is a function, and the second is an iterative object. If you don't understand what a function is, don't know what an iterative object is, remember the following example:
1 def g (x): 2 return 3 * x34 >>> l=map (g,[1,3,4,5,7,10])5 > >> list (l)6 [3, 9, 12, 15, 21, 30]
The defined g (x) is the first parameter of map (), which is three times times the function of the parameter x.
The [1,3,4,5,7,10] list is the second parameter of G (x), which is a list. Yes, the list is an iterative object, of course, the iterative object is not only a list, but others can learn slowly. After calling the map function, g (x) will act on each element of the list, and we'll look at the effect after the effect:
[3, 9, 12, 15, 21, 30]
Yes, each element of L is three times times the original.
The function should understand.
An iterative object should be understood.
The point is, the map () function will work.
Congratulations!
Time is limited, and the following article will explain the reduce function in the simplest way.
How to use the built-in function map () and reduce () in Python3