Python - Accessing, Creating, Updating
Code Life
By Pierre Marsaa
Accessing Dictionary Values with Square Brackets
To access a value in a dictionary, use square brackets [] with the key inside. This is similar to how you access elements in a list, but instead of using an index number, you use the key.
↗️
Loading editor...
↶
↷
The syntax is: dictionary_name[key]
When you use the correct key, Python returns the corresponding value. Make sure the key exists in the dictionary, otherwise you'll get a KeyError!
Verify