119. Lambda Functions in map and filter
numbers = [1, 2, 3, 4, 5]
doubled = list(map(lambda x: x * 2, numbers))
print(doubled) # Output: [2, 4, 6, 8, 10]strings = ["1", "2", "3", "4"]
integers = list(map(lambda x: int(x), strings))
print(integers) # Output: [1, 2, 3, 4]numbers = [1, 2, 3, 4, 5, 6]
evens = list(filter(lambda x: x % 2 == 0, numbers))
print(evens) # Output: [2, 4, 6]words = ["apple", "bat", "cat", "elephant"]
filtered_words = list(filter(lambda x: len(x) == 3, words))
print(filtered_words) # Output: ['bat', 'cat']Last updated