Python Programming - Lambda Functions - Discussion

Discussion Forum : Lambda Functions - General Questions (Q.No. 56)
56.
What is the output of the following code?
items = ['apple', 'banana', 'cherry']
filtered = list(filter(lambda x: 'a' in x, items))
print(filtered)
['apple', 'banana', 'cherry']
['apple', 'banana']
['apple']
['banana']
Answer: Option
Explanation:
The filter() function with the lambda filters items containing the letter 'a'.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.