Sitemap

Dictionary

Nov 30, 2022

--

Dictionaries are used to store data values in key: value pairs. It is an unordered collection of key-value pairs.

Dictionaries are written in curly brackets {} , with keys and values, commonly referred to as Key: value pairs.

It is generally used when we have a huge amount of data, and it’s mutable, just like a list. This means that it could be changed after it’s been created.

Get Habeeb Abdulrauf’s stories in your inbox

Join Medium for free to get updates from this writer.

Dictionaries are optimized for retrieving data. We must know the key to retrieve the value.

Press enter or click to view image in full size

But hey, Dictionaries cannot have two items with the same key:

Example of Dictionary. Capital_and_capital = {“Oyo”: “Ibadan”,”Lagos”: “Ikeja”,”kwara” : Ilorin,”Ogun “: “Abeokuta”, “Niger”: “Minna”}.

PS: Python dictionary is just like our traditional dictionary. Where we have words (i. e key in python) and their meanings ( i. e value pairs in python).

--

--

Habeeb Abdulrauf
Habeeb Abdulrauf

Written by Habeeb Abdulrauf

Python l Data Analytics l Web Solution l Curious Learner l Digital Marketing Consultant l SEO Expert l SDGs. My website : https://habeebabdulrauf.com