map
is a useful method that allows you to apply a function to elements in a list. However, it can’t apply a function with more than one argument to a list.
To apply a function with more than 2 arguments to elements in a list, use itertools.starmap
. With starmap
, elements in each tuple of the list nums
are used as arguments for the function multiply
.