Python Dictionary update() Method Tutorial

In this section, we will learn what the Dictionary update() method is and how to use it in Python.

What is Dictionary update() Method in Python?

The Python Dictionary update() method is used to add new items to a dictionary.

These new items could be in a dictionary or an iterable object with key/value pairs in it.

Python Dictionary update() Method Syntax:

dictionary.update(dictionary)

Dictionary update() Method Parameter:

The method takes one argument and that is a reference to a dictionary or an iterable object that has pairs of key/value.

Dictionary update() Method Return Value

The method does not return a value.

Example: using python dictionary update() method

dictionary = {

"name":"John",

"lastName":"Doe"

}

dictionary.update({"age":2000})

print(dictionary)

Output:

{'name': 'John', 'lastName': 'Doe', 'age': 2000}
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies