Python Language Dictionary: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 28: Line 28:
==Get All Values==
==Get All Values==


=Change a Dictionary=
=Modify a Dictionary=
==Change Individual Elements==
== Modify Individual Elements==
Add, modify, delete.
Add, modify, delete.


==Combine Dictionaries==
==Combine Dictionaries==

Revision as of 19:47, 16 February 2022

Internal

Overview

Create a Dictionary

Empty map

m = {}

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.

Access:

d["key"]

Get All Keys

Get All Values

Modify a Dictionary

Modify Individual Elements

Add, modify, delete.

Combine Dictionaries