Chapter 5: Data Structures
Lists
# An empty list
my_list = []
# A list with integers
numbers = [1, 2, 3, 4, 5]
# A mixed-type list
mixed = [1, "hello", 3.14, True]numbers = [10, 20, 30, 40]
print(numbers[0]) # Output: 10
print(numbers[-1]) # Output: 40 (last element)numbers[1] = 25
print(numbers) # Output: [10, 25, 30, 40]Tuples
Dictionaries
Sets
Summary of Differences
Exercises
Last updated