CodeMasteryLab
Section 4

Data Structures

Lists, tuples, dictionaries, and sets

Data Structures

Master Python's built-in data structures.

Lists

numbers = [1, 2, 3, 4, 5]
numbers.append(6)
numbers[0] = 10

Dictionaries

person = {
    "name": "Alice",
    "age": 30,
    "city": "New York"
}

print(person["name"])
person["email"] = "alice@example.com"

Sets

fruits = {"apple", "banana", "orange"}
fruits.add("grape")