How to Copy a Dictionary with Copy() Method in Python


In this example we will show how to make a copy of a dictionary with the copy() method in Python.

Source Code

mydict = {
  'name': 'Steven',
  'age': 24,
  'ID': 123456
}

mydict_1 = mydict.copy()
print(mydict_1)

Output:

{'name': 'Steven', 'age': 24, 'ID': 123456}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments