Comprehensions and functional programming · 15 / 15 Exercise Medium

Double the positives

Objective

Create a Python program that filters and transforms a list of numbers with filter and map.

Instructions

  • Read a line with integers separated by spaces.
  • With filter and a lambda function, keep only the positive numbers (greater than 0).
  • With map and another lambda, multiply each of them by 2.
  • Show the results on a single line, separated by a space, in the same order as the input.
  • If there is no positive number, show None.
Input
3 -1 4 0 -5 2
Output
6 8 4

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise