Copyright © tutorialspoint.com

Python dictionary copy() Method

previous next


Description:

This class method returns a shallow copy of the dictionary.

Syntax:

dict.copy()

Example:

#!/usr/bin/python

dict1 = {'Name': 'Zara', 'Age': 7};

dict2 = dict1.copy()
print "New Dictinary : %s" %  str(dict2)

This produces following result:

New Dictinary : {'Age': 7, 'Name': 'Zara'}

previous next

Copyright © tutorialspoint.com