Creating and Editing a Dictionary Part 2

Joseph Hart
Jan 14, 2021

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.

--

--