How to Change Value in Python Dictionary?
Hi Friends,
Now, let's see post of how to change value in python dictionary. I explained simply step by step how to replace value in dictionary python. we will help you to give an example of python dictionary change value. This example will help you python dictionary replace value example. Here, Create a basic example of how to change value in dictionary python.
There are several ways to change item values from a dictionary in python. i will give you two examples using update() and using key in python.
So, without further ado, let's see simple examples:
Example 1:
main.py
user = {
"ID": 1,
"name": "Hardik Savani",
"email": "[email protected]"
}
# Update Item from dictionary
user["email"] = "[email protected]"
print(user)
Output:
{
'ID': 1,
'name': 'Hardik Savani',
"email": '[email protected]'
}
Example 2:
main.py
user = {
"ID": 1,
"name": "Hardik Savani",
"email": "[email protected]"
}
# Update Item from dictionary
user.update({"email": "[email protected]"})
print(user)
Output:
{
'ID': 1,
'name': 'Hardik Savani',
"email": '[email protected]'
}
I hope it can help you...
