A dictionary contains the pair of the keys & values (represents key : value), a dictionary is created by providing the elements within the curly braces ({}), separated by the commas.
Here, we have a dictionary and two values whose position is to be swapped.
Program to swap the position of dictionary items
Output:
Initial dictionary = {'Scala': 2, 'C++': 1, 'Python': 8, 'Java': 4, 'Javascript': 5} Dictionary after swapping = {'Scala': 2, 'C++': 1, 'Python': 8, 'Java': 4, 'Javascript': 5}need an explanation for this answer? contact us directly to get an explanation for this answer