We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Zipmap

Let's practice another simple recursive function.

You may not understand recursion just yet, but by following the instructions, you will begin to grasp the fundamentals.

Assignment

Within Doc2Doc we need to map certain properties from one document to properties of another document. Complete the recursive zipmap function.

It takes two lists as input and returns a dictionary where the first list provides the keys and the second list provides the values.

Example usage:

zipped: dict[str, float] = zipmap(
    ["Avatar: The Last Airbender", "Avatar (in Papyrus font)", "The Last Airbender (Live Action)"],
    [9.9, 6.1, 2.1]
)

print(zipped)
# {
#   'Avatar: The Last Airbender': 9.9,
#   'Avatar (in Papyrus font)': 6.1,
#   'The Last Airbender (Live Action)': 2.1,
# }

Here's the pseudocode: