Python Dictionary | update method in python – my programming school


Python Dictionary | update method in python

 Dict in Python_ is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dict.. holds key : value pair.

In Python3 Dict., update() method updates the dictionaries with the elements from the another dictionaries object or from an iterable of key/value pairs.

It use to replace which is already is used and add more data into dictionaries

example 

For more code search python dictionary in search box.

print(f’Before to update userinformation:

{user_info}')

OUTPUT

Before to update userinformation: {'name': 'pramod
', 'age': 22, 'rollno': '17691a05b9', 
'class': 'B-Tech'}
more_info={'name':'pramod kumar yadav','state':
 'Janakpur','country':'Nepal'}
user_info.update(more_info)
print(f'After update user information{user_info}')
 

OUTPUT

After update user information {'name': 
'pramod kumar yadav', 'age': 22, 'rollno': 
'17691a05b9', 'class': 'B-Tech', 'state': 
'Janakpur', 'country': 'Nepal'}

 

Recommend

Python Dictionary | update method in python

Tags:

python dictionary,Python dictionary example,Python dictionary operations,How to create dictionary in python,Algorithm of Pyhton dictionary,python empty dictionary,python dictionaries example,python dictionary example code,python dictionary functions,python dictionary access,python dictionary items,

dict. in python

Have any Question or Comment?

One comment on “Python Dictionary | update method in python – my programming school

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories