logo CodeStepByStep logo

collection_mystery2

Language/Type: Python collection mystery collections

Write the output that is printed when the given function below is passed each of the following pairs of dictionaries as its parameter. Your answer should display the right keys and values in the order they are added to the resulting dictionary.

def collection_mystery2(map1, map2):
    result = {}
    for s1 in map1.keys():
        if map1[s1] in map2:
            result[s1] = map2[map1[s1]]
    return result
map1 = {'bar': 1, 'baz': 2, 'foo': 3, 'mumble': 4}, map2 = {1: 'earth', 2: 'wind', 3: 'air', 4: 'fire'}
map1 = {'five': 105, 'four': 104, 'one': 101, 'six': 106, 'three': 103, 'two': 102}, map2 = {99: 'uno', 101: 'dos', 103: 'tres', 105: 'cuatro'}
map1 = {'a': 42, 'b': 9, 'c': 7, 'd': 15, 'e': 11, 'f': 24, 'g': 7}, map2 = {1: 'four', 3: 'score', 5: 'and', 7: 'seven', 9: 'years', 11: 'ago'}

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.