copy() - Returns a copy of the dictionary

Copies all the items in the dictionary to another dictionary.  Changes to the old dictionary do not the copied dictionary, and changes in the copied dictionary do not affect the old dictionary.


oldProducts = {
    'toothbrush': 2.50, 
    'tomato soup': 1.99

newProducts = oldProducts.copy()

oldProducts['toothbrush'] = 1.75 # change the old product price
newProducts['toothpaste'] = 3.95 # add a new product

print(f'Old products: {oldProducts}')
print(f'New products: {newProducts}')


Old products: {'toothbrush': 1.75, 'tomato soup': 1.99}
New products: {'toothbrush': 2.5, 'tomato soup': 1.99, 'toothpaste': 3.95}