itertools.starmap: Apply a Function With More Than 2 Arguments to Elements in a List

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.

Link to my previous tips about itertools.

Related Posts

Related Posts

Scroll to Top