Search⌘ K

Dictionaries

Explore how to create and use Python dictionaries as unordered collections of unique key value pairs. Understand key membership testing, accessing values, and dictionary keys views to write efficient programs combining dictionaries with other data types.

We'll cover the following...

Python dictionary is basically a hash table or a hash mapping. In some languages, they might be referred to as associative memories or associative arrays. They are indexed with keys, which can be any immutable type. For example, a string or number can be a key. You need to be aware that a dictionary is an unordered set of key:value pairs and the keys must be unique. You can get a list of keys by calling a dictionary instance’s keys method. To check if a dictionary has a key, you can use Python’s in keyword. In some ...