Challenge 2: Invert a Dictionary — Possible Solution ==================================================================== capitals = {"France": "Paris", "Japan": "Tokyo", "Italy": "Rome"} inverted = {city: country for country, city in capitals.items()} print(inverted) Output: {'Paris': 'France', 'Tokyo': 'Japan', 'Rome': 'Italy'} WHY THIS WORKS AS AN ANSWER ------------------------------ capitals.items() reuses the chapter's own .items() method to produce (key, value) pairs — here (country, city) pairs like ("France", "Paris") — which the comprehension unpacks directly in its for clause, the same tuple-unpacking-in-a-loop-header idiom from the previous chapter's coordinate example. The dict comprehension {city: country for country, city in ...} mirrors the {k: v for ...} pattern from this chapter's dict comprehension section exactly, except the expression before the for deliberately swaps the two names — city becomes the new key, country becomes the new value — which is precisely what "inverting" a dictionary means: keys and values trade places. This only produces a clean, fully reversible result because the original values ("Paris", "Tokyo", "Rome") are themselves unique; if two countries shared the same capital, one entry would silently overwrite the other in the inverted dictionary, since dictionary keys must be unique.