174k views
1 vote
Hi everyone,

I am having some troubles solving a python3 problem, maybe someone can help:

If we have the following array:
l = [10, 11, 0, 2]

By using map and filter function we should list:
["Even", "Odd", "Even", "Even"]

Thank you!​

User Delando
by
5.4k points

1 Answer

4 votes

Answer:

Step-by-step explanation:

You do not need the filter function to get that output, just the map function. You will however need a function that checks each element and returns Even or Odd if they are or not. The following code gives the output that you want as can be seen in the picture below.

def checkEven(s):

if s % 2 == 0:

return "Even"

else:

return "Odd"

l = [10, 11, 0, 2]

print(list(map(checkEven, l)))

Hi everyone, I am having some troubles solving a python3 problem, maybe someone can-example-1
User Steve Brouillard
by
6.0k points