Easy Tutorial
❮ Python Area Of A Circle Python String Zfill ❯

Python3 Dictionary update() Method

Python3 Dictionary


Description

The Python dictionary update() function updates the dictionary with the key/value pairs from dict2, overwriting existing keys.

Syntax

The syntax for the update() method is:

dict.update(dict2)

Parameters

Return Value

This method does not return any value.

Example

The following example demonstrates the use of the update() function:

Example (Python 2.0+)

#!/usr/bin/python3

tinydict = {'Name': 'tutorialpro', 'Age': 7}
tinydict2 = {'Sex': 'female' }

tinydict.update(tinydict2)
print("Updated dictionary tinydict : ", tinydict)

The output of the above example is:

Updated dictionary tinydict :  {'Name': 'tutorialpro', 'Age': 7, 'Sex': 'female'}

Python3 Dictionary

❮ Python Area Of A Circle Python String Zfill ❯