Your task
From [1, 2, 3, 4, 5, 6], use filter with a lambda to keep the even numbers. Print the list.
Expected output
[2, 4, 6]
Worked solution
nums = [1, 2, 3, 4, 5, 6]
print(list(filter(lambda n: n % 2 == 0, nums)))
Checks compare printed output, not your approach. Several solutions can be valid.
← Back to courses