Copy Dictionaries
We can use the copy() method to copy the contents of one dictionary into another dictionary.
Example:
info = {'name':'Karan', 'age':19, 'eligible':True, 'DOB':2003}
newDictionary = info.copy()
print(newDictionary)
Output:
{'name': 'Karan', 'age': 19, 'eligible': True, 'DOB': 2003}
Or we can use the dict() function to make a new dictionary with the items of the original dictionary.
Example:
info = {'name':'Karan', 'age':19, 'eligible':True, 'DOB':2003}
newDictionary = dict(info)
print(newDictionary)
Output:
{'name': 'Karan', 'age': 19, 'eligible': True, 'DOB': 2003}