Python - Add Dictionary Items
Python - Add Dictionary Items
Dark mode
Dark code
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP BOOTSTRAP HOW TO W3.CSS C C++ C# REACT R JQUERY DJANGO
Python Tutorial
ADVERTISEMENT
Python HOME
Python Intro
Python Get Started
Python Syntax
Update Dictionary
The update() method will update the dictionary with the items from a given argument. If the item does not exist, the item will
be added.
Example
COLOR PICKER
Add a color item to the dictionary by using the update() method:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict.update({"color": "red"})
Try it Yourself »
ADVERTISEMENT
ADVERTISEMENT
FORUM | ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.