Single variables hold one value. Collections hold many β and that changes everything. Lists and dictionaries are the backbone of real programs.
Ordered sequences with indexing, slicing, and len().
append(), insert(), remove(), pop() β lists are mutable!
for item in list, enumerate(), search, filter, transform.
Key-value pairs for labeled data: contacts, inventories, configs.
.keys(), .values(), .items() β loop through labeled data.
Combine everything into a full contact manager.
Two ways to organize data β choose based on how you'll look it up.
Click any lesson to see its challenges.
Create lists, access elements by index (positive & negative), use len(), and slice to extract portions.
Add, remove, and rearrange list items with append(), insert(), remove(), pop(), and the in keyword.
Loop through lists with for item in list and enumerate(). Search, filter, and transform data.
Store labeled data with dictionaries. Access, add, update entries and handle missing keys safely with get().
Loop through dicts with .keys(), .values(), .items(). Build dicts from data and work with nested structures.
Build a full contact manager app: store contacts as a list of dictionaries, support add/search/delete/list operations via a menu loop.
Lesson 4.1 introduces lists β Python's most versatile data structure.
Begin Lesson 4.1 β