logo CodeStepByStep logo


Language/Type: Python collections dict

What keys and values are contained in the following dictionary after this code executes?

number_words = {}
number_words[8] = "Eight"
number_words[41] = "FortyOne"
number_words[8] = "Ocho"
number_words[18] = "Eighteen"
number_words[50] = "Fifty"
number_words[132] = "OneThreeTwo"
number_words[28] = "TwentyEight"
number_words[79] = "SeventyNine"
del number_words[41]
del number_words[28]
if "Eight" in number_words:
    del number_words["Eight"]
number_words[50] = "FortyOne"
number_words[28] = "18"
del number_words[18]

(Though dictionaries store their contents in unpredictable order, for this problem, write the pairs sorted by numeric value of the keys, in the format {key: 'value', key: 'value'}.)

dictionary contents

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.