myList = [1, 2, 3, 4, 5]
filtered = list(filter(lambda x: x%2==0, myList))
# ^ ^ ^ ^ ^ ^ ^ ^ ^
# function that returns boolean
# OR
filtered = [x for x in myList if x%2==0]
# ^ ^ ^
# condition
friends = [
{'name': 'Sam', 'gender': 'male', 'sport': 'Basketball'},
{'name': 'Emily', 'gender': 'female', 'sport': 'Volleyball'}
]
# filter by column names
print([{key: friend[key] for key in friend.keys() if key in ["name", "sport"]} for friend in friends])
# filter by rows
print([a for a in friends if a["name"] in ["Sam"]])