Dictionary update() method

In Python Dictionary update() method is used to update the dictionary with the elements from another dictionary object.

Syntax:
Update() method take dictionary or an iterable object of key pairs mostly tuples as Parameters.
Example:
#methods in Dictionary
  
Dict1 = { 'Name': 'JOY', 'Age': '20', }
Dict2 = { 'Age': '21' }
  
#before Updation
print("Original Dictionary:")
print(Dict1)
  
#after Updation 
Dict1.update(Dict2)
print("Dictionary after updation:")
print(Dict1)

Comments are closed.