Python | Copy dictionary
Built in Method copy() used for copy a dictionary
Example
dictionary = {
"Fname": "neel",
"Sname": "patel",
"Year": 1999
}
Dictionary = dictionary.copy()
print(Dictionary)
Output
{'Fname': 'neel', 'Sname': 'patel', 'Year': 1999}
Also you can use built in method dict() for copy a dictionary
Example
dictionary = {
"Fname": "neel",
"Sname": "patel",
"Year": 1999
}
Dictionary = dict(dictionary)
print(Dictionary)
Output
{'Fname': 'neel', 'Sname': 'patel', 'Year': 1999}