Python Dictionary Update method- my programming school

Python Dictionary Update method with example

 Dictionary in Python is an unordered group of data values, used to store data values like a map, which, unlike other data types that carry only a single value as an element, Python dictionary holds pair. In Python Dictionary update method updates the dictionaries with the elements from different dictionary object or from an iterable of key/value pairs.

It uses to replace what is already is used and add more data to dictionaries

Syntax:

dictionary.update(iterable)

Python dictionary update method Example 

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

OUTPUT

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
Before to update userinformation:{'name': 'pramod', 'age': 22, 'rollno': '17691a05b9', 'class': 'B-Tech'}
more_info={'name': 'pramod kumar yadav', 'state': 'Janakpur', 'country': 'Nepal'}
After update user information{'name': 'pramod kumar yadav', 'age': 22, 'rollno': '17691a05b9', 'class': 'B-Tech', 'state': 'Janakpur', 'country': 'Nepal'}

Process finished with exit code 0
Python Dictionary Update method

Recommend:

learn salesforce

Pramod Kumar Yadav is from Janakpurdham, Nepal. He was born on December 23, 1996, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India.He is director of Appan Bazaar Pvt.Ltd., as teacher in Tridev Eng. School , and an Educational Consultant, and he is currently working as a developer and Digital Marketer.



1 thought on “Python Dictionary Update method- my programming school”

Leave a Comment