Python Data Structures
Learning Path ⋅ Skills: Python, Strings, Lists, Tuples, Dictionaries, Sets, List Comprehensions, range()
![A person pointing on a screen that transforms a digital data structure representation into a real-life one based on square objects](https://files.realpython.com/media/pcl-Python-Tricks-Chapter-on-Data-Structures_Watermarked.01bffa7044af.jpg)
Explore Python’s core data structures: strings, lists, tuples, dictionaries, and sets. Master string operations, list comprehensions, copying objects, sorting, and the range() function. Dive deep into complex numbers, the del statement, and robust assignments.
Python Data Structures
Learning Path ⋅ 18 Resources
![Title image for Strings and Character Data in Python (Strings and Character Data in Python)](https://files.realpython.com/media/Strings-and-Character-Data-in-Python_Watermarked.797803948b10.jpg)
Course
Strings and Character Data in Python
Learn how to use Python's rich set of operators, functions, and methods for working with strings. You'll learn how to access and extract portions of strings, and also become familiar with the methods that are available to manipulate and modify string data in Python 3.
![Title image for Python Strings and Character Data (Strings and Character Data in Python)](https://files.realpython.com/media/Strings-and-Character-Data-in-Python_Watermarked.797803948b10.jpg)
Interactive Quiz
Python Strings and Character Data
![Title image for Check if a Python String Contains a Substring (How to Check if a Python String Contains a Substring)](https://files.realpython.com/media/How-to-Check-if-a-String-Contains-Another-String_Watermarked.ad5138507ec7.jpg)
Course
Check if a Python String Contains a Substring
Learn the best way to check whether a Python string contains a substring. You'll also learn about idiomatic ways to inspect the substring further, match substrings with conditions using regular expressions, and search for substrings in pandas.
![Title image for How to Check if a Python String Contains a Substring (How to Check if a Python String Contains a Substring)](https://files.realpython.com/media/How-to-Check-if-a-String-Contains-Another-String_Watermarked.ad5138507ec7.jpg)
Interactive Quiz
How to Check if a Python String Contains a Substring
![Title image for Splitting, Concatenating, and Joining Python Strings (Splitting, Concatenating, and Joining Strings in Python)](https://files.realpython.com/media/Pythons-split-function--string-concatenation_Watermark.7eade0c24cf0.jpg)
Course
Splitting, Concatenating, and Joining Python Strings
In this course you'll some of the most fundamental string operations: splitting, concatenating, and joining. Not only will you learn how to use these tools, but you’ll walk away with a deeper understanding of how they work under the hood in Python.
![Title image for Lists and Tuples in Python (Lists and Tuples in Python)](https://files.realpython.com/media/Lists-and-Tuples-in-Python_Watermarked.4d655c81a78b.jpg)
Course
Lists and Tuples in Python
See the important characteristics of lists and tuples in Python 3. You'll learn how to define them and how to manipulate them. When you're finished, you'll have a good feel for when and how to use these object types in a Python program.
![Title image for Lists vs Tuples in Python (Lists vs Tuples in Python)](https://files.realpython.com/media/Lists-and-Tuples-in-Python_Watermarked.a52798070b3e.jpg)
Interactive Quiz
Lists vs Tuples in Python
![Title image for Using Dictionaries in Python (How to Iterate Through a Dictionary in Python)](https://files.realpython.com/media/How-to-Iterate-Through-A-Dictionary-in-Python_Watermarked.06d6547f531b.jpg)
Course
Using Dictionaries in Python
In this course on Python dictionaries, you'll cover the basic characteristics of dictionaries and learn how to access and manage dictionary data. Once you've finished this course, you'll have a good sense of when a dictionary is the appropriate data type to use and know how to use it.
![Title image for Python Dictionaries (Dictionaries in Python)](https://files.realpython.com/media/Dictionaries-in-Python_Watermarked.3656a2293c00.jpg)
Interactive Quiz
Python Dictionaries
![Title image for Python's len() Function (Using the len() Function in Python)](https://files.realpython.com/media/Pythons-len-Function_Watermarked.056de9852b3f.jpg)
Course
Python's len() Function
Learn how and when to use the len() Python function. You'll also learn how to customize your class definitions so that objects of a user-defined class can be used as arguments in len().
![Title image for Python's list Data Type: A Deep Dive With Examples (Python's list Data Type: A Deep Dive With Examples)](https://files.realpython.com/media/Pythons-list-Built-in-Data-Type-A-Deep-Dive-With-Examples_Watermarked.1f6291ed72f5.jpg)
Tutorial
Python's list Data Type: A Deep Dive With Examples
In this tutorial, you'll dive deep into Python's lists. You'll learn how to create them, update their content, populate and grow them, and more. Along the way, you'll code practical examples that will help you strengthen your skills with this fundamental data type in Python.
![Title image for Shallow vs Deep Copying of Python Objects (Shallow vs Deep Copying of Python Objects)](https://files.realpython.com/media/Shallow-vs-Deep-Copying-of-Python-Objects_Watermarked.e6471b4627f8.jpg)
Tutorial
Shallow vs Deep Copying of Python Objects
What's the difference between a shallow and a deep copy of a Python object? Learn how to clone arbitrary objects in Python, including your own custom classes.
![Title image for Understanding Python List Comprehensions (When to Use a List Comprehension in Python)](https://files.realpython.com/media/List-Comprehensions-in-Python_Watermarked.39cf85bdd5d0.jpg)
Course
Understanding Python List Comprehensions
Python list comprehensions make it easy to create lists while performing sophisticated filtering, mapping, and conditional logic on their members. In this course, you'll learn when to use a list comprehension in Python and how to create them effectively.
![Title image for When to Use a List Comprehension in Python (When to Use a List Comprehension in Python)](https://files.realpython.com/media/List-Comprehensions-in-Python_Watermarked.39cf85bdd5d0.jpg)
Interactive Quiz
When to Use a List Comprehension in Python
![Title image for Flattening a List of Lists in Python (How to Flatten a List of Lists in Python)](https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.jpg)
Course
Flattening a List of Lists in Python
Learn how to flatten a list of lists in Python. You'll use different tools and techniques to accomplish this task. First, you'll use a loop along with the .extend() method of list. Then you'll explore other tools, including reduce(), sum(), itertools.chain(), and more.
![Title image for How to Flatten a List of Lists in Python (How to Flatten a List of Lists in Python)](https://files.realpython.com/media/How-to-Flatten-a-List-of-Lists_Watermarked.2f9407737589.jpg)
Interactive Quiz
How to Flatten a List of Lists in Python
![Title image for Exploring Python's tuple Data Type With Examples (Python's tuple Data Type: A Deep Dive With Examples)](https://files.realpython.com/media/Pythons-tuple-Built-in-Data-Type-A-Deep-Dive-with-Examples_Watermarked.e85efb14c955.jpg)
Course
Exploring Python's tuple Data Type With Examples
In Python, a tuple is a built-in data type that allows you to create immutable sequences of values. The values or items in a tuple can be of any type. This makes tuples pretty useful in those situations where you need to store heterogeneous data, like that in a database record, for example.
![Title image for Sorting Data With Python (How to Use sorted() and sort() in Python)](https://files.realpython.com/media/The-Python-Sort-Function-Guide_Watermarked.394963ad7eff.jpg)
Course
Sorting Data With Python
In this step-by-step course, you’ll learn how to sort in Python. You'll know how to sort various types of data in different data structures, customize the order, and work with two different ways of sorting in Python.
![Title image for Using Sets in Python (Sets in Python)](https://files.realpython.com/media/Sets-in-Python_Watermarked.cd8d2e9563c3.jpg)
Course
Using Sets in Python
Learn how to work with Python's set data type. You'll see how to define set objects in Python and discover the operations that they support. By the end of this course, you'll have a good feel for when a set is an appropriate choice in your own programs.
![Title image for Python Sets (Sets in Python)](https://files.realpython.com/media/Sets-in-Python_Watermarked.cd8d2e9563c3.jpg)
Interactive Quiz
Python Sets
![Title image for Python's del: Remove References From Scopes and Containers (Python's del: Remove References From Scopes and Containers)](https://files.realpython.com/media/Pythons-del-Statement-Remove-Items-From-Your-Collections_Watermarked.fd5b504e5f73.jpg)
Tutorial
Python's del: Remove References From Scopes and Containers
Learn how Python's del statement works and how to use it in your code. This statement will allow you to remove references from different scopes, items from lists, keys from dictionaries, and members from classes. This will lead to potentially memory-efficient code.
![Title image for Python's Assignment Operator: Write Robust Assignments (Python's Assignment Operator: Write Robust Assignments)](https://files.realpython.com/media/Pythons-Assignment-Statements-How-Do-They-Work_Watermarked.0a994e47f63c.jpg)
Tutorial
Python's Assignment Operator: Write Robust Assignments
Learn how to use Python's assignment operators to write assignment statements that allow you to create, initialize, and update variables in your code.
![Title image for The Python range() Function (Python's range() Function)](https://files.realpython.com/media/Pythons-range-function_Watermark.5e8ea929167e.jpg)
Course
The Python range() Function
In this step-by-step course, you'll master the Python range() function, learn how its implementation differs in Python 3 vs 2, and see how you can use it to write faster and more Pythonic code.
![Title image for Why Are Membership Tests So Fast for range() in Python? (Why Are Membership Tests So Fast for range() in Python?)](https://files.realpython.com/media/Why-is-the-range-Function-So-Fast-in-Python_Watermarked.e6122557d6e6.jpg)
Tutorial
Why Are Membership Tests So Fast for range() in Python?
In Python, range() is most commonly used in for loops. However, ranges have some other use cases too, as they share many properties with lists. In this tutorial, you'll explore why it's so fast to perform a membership test on a Python range.
![Title image for Simplify Complex Numbers With Python (Simplify Complex Numbers With Python)](https://files.realpython.com/media/Complex-Numbers-in-Python_Watermarked.5dcdcdf8b2d1.jpg)
Tutorial
Simplify Complex Numbers With Python
Learn about the unique treatment of complex numbers in Python. Complex numbers are a convenient tool for solving scientific and engineering problems. You'll experience the elegance of using complex numbers in Python with several hands-on examples.
Got feedback on this learning path?
Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!