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.
We have a dictionary consisting of some key-value pairs. We will shuffle the values i.e. the position of keys will be constant but the values attached to the key will be changed randomly.
Example:
Original dictionary:
{'Indore': 2, 'Delhi' : 5, 'Mumbai' : 1, 'Manali' : 3, 'Patna': 8}
Shuffled dictionary:
{'Indore': 1, 'Delhi' : 8, 'Mumbai' : 5, 'Manali' : 2, 'Patna': 3}
Algorithm:
Program to shuffle values of dictionary in Python
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer