Source Code:
(back to article)
my_dict = {"name": "John", "age": 30, "city": "New York"} my_dict["occupation"] = "Software Engineer" # Adding a new item my_dict["age"] = 31 # Modifying an existing item my_dict.update({"city": "San Francisco"}) # Modifying an existing item using update method
Result:
Report an issue