Jul 30, 2021
God, no, it's awful! 😄
Sorry, but it's true. Use a list comprehension! (You do this just below, and it's the only correct solution.)
print([i for i in numbers if i % 2])
map
, filter
and reduce
are effectively deprecated — example. Guido van Rossum was actually in favor of dropping them entirely from Python 3 but it didn’t go that far.
Still, there is literally no reason to use them in modern Python code — generator expressions or list comprehensions are shorter, more powerful, sometimes more performant and never less, and clearer to read.