DEV Community

Discussion on: Understanding map, filter, and zip in Python

Collapse
 
paddy3118 profile image
Paddy3118 • Edited

But remember, in Python comprehensions should be the first try for what could be done in map and filter.

answer = [(x, x**2) for x in numbers if x % 2 == 0]
Collapse
 
codespent profile image
Patrick Hanford

Absolutely, and thanks for commenting this, I hope everyone sees this as well!

Collapse
 
waylonwalker profile image
Waylon Walker

Compressions can typically replace all 3 (map, filter, reduce) and can be used with zip.

The concepts here are still important to know. Libraries like pandas utilize the map syntax, or using a different language like JavaScript.