Lesson 10Diving Deeper into Data Structures: Dictionaries
We've seen how to use lists and tuples to store data, where we can use automatically assigned index values to identify specific values in the collection. Python also supports the use of dictionaries, which give us the ability to define the index values ourselves, and sets, which are unorganized and unindexed. We will discuss dictionaries in this lesson and sets in Lesson 11.
DATA STRUCTURE OVERVIEW—PART 2
In the previous lessons, we introduced data structures in Python with the purpose of explaining, using, and differentiating between lists and tuples. As a quick review: Python supports several built-in data structures. These include strings, lists, tuples, dictionaries, and sets. Let's review these items prior to discussing the next data structure.
Lists, strings, and tuples are ordered sequences of objects. Unlike strings that contain only characters, lists and tuples can contain any type of objects. Lists and tuples are similar to arrays, which are found in other programming languages. Tuples, like strings, are immutable, meaning they cannot be changed. Lists are mutable, so they can be extended or reduced if the need arises.
In this lesson and the ...
Get Job Ready Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.