Member-only story
Dictionaries in Python? | Straightforward Python
In this article, you’ll learn everything about Python dictionaries; how they are created, accessing, adding, removing elements from them and various built-in methods.
Dictionaries are Python’s implementation of a data structure that is more generally known as an associative array. A dictionary consists of a collection of key-value pairs. Each key-value pair maps the key to its associated value.

You can define a dictionary by enclosing a comma-separated list of key-value pairs in curly braces ({}
). A colon (:
) separates each key from its associated value
thisdict = {
"brand": "Apple",
"model": "iPhone 12 pro",
"year": 2020
}
Creating Python Dictionary
Creating a dictionary is as simple as placing items inside curly braces {}
separated by commas as stated above
An item has a
key
and a correspondingvalue
that is expressed as a pair (key: value).
Create and print a dictionary:
thisdict = {
"brand": "Apple",
"model": "iPhone 12 pro",
"year": 2020
}print(thisdict)