Skip to content
UPEEC

map() and filter()

Apply a function to every item, or keep only items that pass a test (both are lazy).

Easy
Comments 0
volts = list(map(float, ["1.2", "3.3"]))
positives = list(filter(lambda x: x > 0, data))

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.