you are not allowed to use pass keyword in conditional expressions(ternary operator)
you can read more about conditional expressions in PEP308
So, if you want to use the map built-in function you have to pick an "else" value for the ternary operator, ex:
map(lambda x : x if x == "apple" else None, ['apple', 'banana', 'cherry'])
or if you want to filter your list by the string "apple" you can use @Rakesh suggested solution by using the built-in function filter:
list(filter(lambda x : x == "apple", ['apple', 'banana', 'cherry']))
passbranch? Note thatmapconverts every input element to an output element. It cannot remove elements.lambdato usemaporfilter, don't. It'll be slower and less readable than an equivalent list comprehension/generator expression that avoids alambdaby inlining the same logic.map/filter, listcomp, genexpr).