Editor settings

General settings

Save settings

Learn to program with Python

Modifying dictionary values #

You can also modify the value of a key by re-assigning it:

my_dict = {
    "name": "John",
    "age": 25,
    "city": "New York",
}

my_dict["age"] = 26
print(my_dict["age"]) # 26

As you can see, the my_dict["age"] was 25 before we reassigned it to 26.


Exercise #

We have created a dictionary job_position. Change the value of the key "experience_required" to the value other than 5.

Tests #

  • job_position["experience_required"] should be any value other than 5
  • Update the value using square brackets []
Output will be displayed here