Dictionaries in Python

--Originally published at Programming

Today we’ll be talking about the Dictionaries in Python. A Dictionary and a List share a lot of things in common, the only difference is that you can get the data out of a Dictionary using almost anything, on the other hand, when using a list, the only way to get the data was by using the value’s position. In other words, a Dictionary is like a database for storing and organizing data.

A Dictionary let’s you use anything, not just numbers, to get the elements of the Dictionary and to modify them. Basically a Dictionary associates one thing to another. Let’s see how a Dictionary is created by associating values to strings.1.png

2.png

As you can see, unlike the list, here we are using strings to get the values we want from the dictionaryExample. But keep in mind that you are allowed to use also numbers just like in a list. But what if we want to delete elements from the dictionary? You need to use the del keyword like this:

3.png

4.png