Exercise: Swap dictionary keys and values

Iterate over the key-value pairs of the capitals dictionary and assign swapped key-value pairs to swapped_dict.
capitals = { 'USA': 'Washington D.C.', 'France': 'Paris', 'Brazil': 'Brasília', 'Peru': 'Lima' } swapped_dict = {} for key, value in capitals.items(): # assign swapped key-value pair to swapped_dict
print(swapped_dict) # expected output: # { # 'Washington D.C.': 'USA', # 'Paris': 'France', # 'Brasília': 'Brazil', # 'Lima': 'Peru' # }
Python
Setting up Python environment...
Output