Map Abstraction

Map

Syntax

Map applies a function, f, to all element of a list, list.

map(f, list)

Example

items = [1, 2, 3, 4, 5]
squared = list(map(lambda x: x**2, items))
#output [2, 4,  6, 8, 10]

Last updated