Creating and Editing a Dictionary Part 2

In Python, dictionaries are powerful resources that are capable of storing a lot of information. I. this post, I will show you how to create a dictionary with multiple elements and how to delete one of those items.

Let’s name our dictionary people and add our elements.

We have three keys: Steve, Tim, and Frank. Each of these keys has two values, age and last name. If we want to pull our first item, we will do the following:

If we wanted to pull the values for the first key, we would input the following:

If we want to delete a key and its values from our dictionary, we can use the del function.

So now the dictionary no longer includes the Steve key or any of its values.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store