Python Language Dictionary: Difference between revisions
Jump to navigation
Jump to search
Line 14: | Line 14: | ||
=Create a Dictionary= | =Create a Dictionary= | ||
=Access a Dictionary= | =Access a Dictionary= | ||
==Access Individual Elements== | |||
<code>[]</code>, <code>get()</code> | |||
An attempt to access an inexistent key ends up in a <code>KeyError</code> exception being thrown. | An attempt to access an inexistent key ends up in a <code>KeyError</code> exception being thrown. | ||
Test the existence of a key. | Test the existence of a key. | ||
==Get All Keys== | |||
==Get All Values== | |||
=Change a Dictionary= | =Change a Dictionary= |
Revision as of 19:44, 16 February 2022
Internal
Overview
Empty map
m = {}
Access:
d["key"]
Create a Dictionary
Access a Dictionary
Access Individual Elements
[]
, get()
An attempt to access an inexistent key ends up in a KeyError
exception being thrown.
Test the existence of a key.
Get All Keys
Get All Values
Change a Dictionary
Individual Elements
Add, modify, delete.