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.
There are some of the ways to copy dictionaries,
- Using the copy() method
- Using the dict() method
1) Copy dictionaries using the copy() method
The copy() method is a built-in method in Python, which can be used to create a copy of the dictionary.
Syntax:
Program:
Output:
2) Copy dictionaries using the dict() method
The dict() method is a built-in method in Python, which is used to create a new dictionary and can also be used to create a copy of the dictionary by creating a new dictionary from an existing dictionary.
Syntax:
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer