Dictionary
Assigning a new value to an existing key is simple - as dictionaries are fully mutable, there are no obstacles to modifying them.
We're going to replace the value "chat" with "minou", which is not very accurate, but it will work well with our example.
Look:
The output is:
Adding a new key
Adding a new key-value pair to a dictionary is as simple as changing a value - you only have to assign a value to a new, previously non-existent key.
Note: this is very different behavior compared to lists, which don't allow you to assign values to non-existing indices.
Let's add a new pair of words to the dictionary - a bit weird, but still valid:
The example outputs:
Last updated