Copyright © tutorialspoint.com

Python dictionary update() Method

previous next


Description:

This class method adds dictionary dict2's key-values pairs in to dict. This function does not return anything.

Syntax:

dict.update(dict2)

Parameters:

Here is the detail of parameters:

Example:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7}
dict2 = {'Sex': 'female' }

dict.update(dict2)
print "Value : %s" %  dict

This produces following result:

Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}

previous next

Copyright © tutorialspoint.com