ThePythonBook

Data Structures

Lists, tuples, dictionaries, sets, and complex data handling

10tutorials
63exercises
240minutes
905XP
10 tutorials in this category

Python Lists: Create, Access, Modify, and Loop Through Lists

The most-used data structure in Python. Create lists, modify them, sort them, loop through them, and start thinking in collections.

beginner30m8145

Python Comprehensions: List, Dict, Set, and Generator in One Guide

Turn verbose loops into elegant one-liners. List, dict, set, and generator comprehensions with filtering and conditional logic.

intermediate30m8115

Python Tuples: When and Why to Use Immutable Sequences

Immutable sequences for data that shouldn't change. Tuple packing, unpacking, named tuples, and when to pick tuples over lists.

beginner20m560

Python Dictionaries: The Complete Guide with Real Examples

Key-value pairs are fundamental to Python. Create dicts, access nested data, loop through them, and pick up patterns you'll reuse everywhere.

beginner30m8110

Python Sets: Unique Collections, Operations, and Use Cases

Unique, unordered collections. Great for deduplication, membership testing, and set math — union, intersection, difference.

intermediate20m685

Python Slicing: Master Indexing for Strings, Lists, and Tuples

The start:stop:step notation that works on strings, lists, and tuples. Reverse sequences, grab subsets, and use negative indices.

beginner20m680

Python Unpacking: Starred Expressions, Swapping, and Destructuring

Assign multiple values at once, swap variables without a temp, and use * to capture the rest. A small feature you'll use surprisingly often.

intermediate20m570

Python Sorting: sort(), sorted(), Key Functions, and Custom Order

sort() vs sorted(), reverse, key functions, and lambda-based custom ordering. Sort any data exactly the way you need.

intermediate25m685

Working with Nested Lists, Dicts, and Complex Data Structures

Lists of dicts, dicts of lists, JSON-like structures — how to access, modify, and iterate through complex nested data in Python.

intermediate25m685

Python Copy vs Deepcopy: Why Your 'Copy' Isn't Really a Copy

Why changing a 'copy' sometimes changes the original. Shallow vs deep copy, aliasing traps, and how to safely duplicate mutable objects.

intermediate20m570