How to Make a Copy of a Dictionary with Dict() Function in Python


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

Source Code

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

mydict_1 = dict(mydict)
print(mydict_1)

Output:

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