From the course: Python Data Structures: Dictionaries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using Python lists within a dictionary

Using Python lists within a dictionary - Python Tutorial

From the course: Python Data Structures: Dictionaries

Start my 1-month free trial

Using Python lists within a dictionary

- [Narrator] In this video, we are going to discuss a dictionary of lists. A list is a very fundamental data structure any programming language. A dictionary is a very versatile data structure in Python, so any program that has both these data structures are very powerful, so this lesson which covers both together is a very important lesson. A dictionary key can only be immutable. This means that a list data structure cannot be a key, but a key can most certainly hold a list of values. Values don't have to be immutable. They are mutable. So in this example, we are going to use a dictionary of words. Many words in an English dictionary have more than one meaning. We call them synonyms. Here is a pre-written program which has a empty dictionary, eng_di, as you see in line one. I've created an empty dictionary. Lines three and four create two keywords, solitude and hope, and each of them is assigned a list of…

Contents