SNIPPET
2 Upvotes

Filter Python Lists with Lambda

Python
General Python

Uses lambda to filter the original list so only values over 14 are included in the new iterable. Note: the created iterable is converted back into a list.

original_list = [11, 13, 15, 17]

filtered_list = list(filter(lambda x: x > 14, original_list))

>> [15, 17]

By detro - Last Updated Oct. 30, 2021, 1:24 p.m.

COMMENTS
RELATED SNIPPETS
Python For Else Loop
Python
General Python

Loop

2
1
Search Snippets by Tag: