The method copy() returns a shallow copy of the dictionary.
Following is the syntax for copy() method:
dict.copy()
NA
This method returns a shallow copy of the dictionary.
The following example shows the usage of copy() method.
#!/usr/bin/python dict1 = {'Name': 'Zara', 'Age': 7}; dict2 = dict1.copy() print "New Dictinary : %s" % str(dict2)
When we run above program, it produces following result:
New Dictinary : {'Age': 7, 'Name': 'Zara'}