@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1593 / 12833)
You can use the update() function to copy the keys and values of one dictionary into another.
I made a sample by referring to the code in the book.
http://ideone.com/uMxSqe
equipment = { 'item1': 'double edged sword', 'item2': 'Korejanai Robo'}
print(equipment)
second = {'item2': 'Delta Flyer'}
equipment.update(second)
print(equipment)
result
{'item2': 'Korejanai Robo', 'item1': 'double edged sword'}
{'item2': 'Delta Flyer', 'item1': 'double edged sword'}
Recommended Posts