Python Language Dictionary

From NovaOrdis Knowledge Base
Revision as of 19:47, 16 February 2022 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

Internal

Overview

A dictionary is a mutable collection of key-value pairs. The pairs can be accessed and modified.

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