Skip to content
C

Filter and Transform Pipeline

Mediumpython

Given a list of numbers, use filter() to keep only the even numbers, then use map() to square each of them, and print the final result as a list.

What the problem means: this chains two higher-order functions together — first narrow the list down (filter), then transform what's left (map).

Approach: filter(lambda x: x % 2 == 0, numbers) keeps only even numbers; map(lambda x: x ** 2, ...) squares each of those; wrap the final result in list(...) to see the values.

Input: One line: space-separated whole numbers.

Output: One line: the squares of the even numbers, printed as a Python list, in their original order.

Input (stdin)

Output

Run your code to see output here...