December 2022
Beginner to intermediate
512 pages
14h 57m
English
Python comes with built-in container objects. These objects store data and are also iterable, meaning there is a mechanism to iterate through the values stored in the container.
Lists are a fundamental data structure in Python. They are used to store heterogeneous data and are created with a pair of square brackets, [ ].
my_list = ['a', 1, True, 3.14]
print(my_list)
['a', 1, True, 3.14]
We can subset the list using square brackets and provide the index of the item we want.
# get the first item - index 0
print(my_list[0])
a
We can also pass in a range of values (Appendix P).
# get the first 3 values
print(my_list[:3])
['a', 1, ...Read now
Unlock full access