Comprehensions and functional programming · 9 / 15 Exercise Easy

Label evens and odds

Objective

Create a Python program that replaces each number with a label depending on whether it is even or odd, using a comprehension with if/else.

Instructions

  • Read a line with integers separated by spaces.
  • With a comprehension with if/else, generate "E" for even numbers and "O" for odd ones.
  • Show the labels on a single line, separated by a space.
Input
1 2 3 4
Output
O E O E

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

Start exercise