What is difference between Map() and Filter () function in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is difference between Map() and Filter () function in Python

6th Jul 2019, 7:59 AM
Anurag Kumar
Anurag Kumar - avatar
2 Answers
+ 4
They are completely different. map() works through each element of the list and does some transformation on each element. So in the end the result list will be the same size. filter() has a predicate function as parameter, that means it transforms each list element to boolean True/False values, and it keeps only the truthy ones. So the size of your list can shrink, and also you will keep the original list elements without transformation.
6th Jul 2019, 8:13 AM
Tibor Santa
Tibor Santa - avatar