Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python map and filter code

Practice transforming, selecting, combining iterables, and composing map with filter.

Beginner ~6 min read

Challenge 1

Use map to double every number.

python Your answer
values = [2, 4, 6]
result = 
print(list(result))

Press Ctrl⌘Enter to check your answer

Challenge 2

Keep only the even numbers.

python Your answer
values = [1, 2, 3, 4]
result = 
print(list(result))

Press Ctrl⌘Enter to check your answer

Challenge 3

Map add across two iterables.

python Your answer
def add(left, right):
    return left + right

left = [1, 2]
right = [10, 20]
result = 
print(list(result))

Press Ctrl⌘Enter to check your answer

Challenge 4

Remove empty names, then clean the remaining names.

python Your answer
def clean(name):
    return name.strip().title()

raw = [" ada ", "", " grace "]
result = 
print(list(result))

Press Ctrl⌘Enter to check your answer