May 2019
Beginner
528 pages
29h 51m
English
Here, we discuss lists in more detail and explain how to refer to particular list elements. Many of the capabilities shown in this section apply to all sequence types.
Lists typically store homogeneous data, that is, values of the same data type. Consider the list c, which contains five integer elements:
In [1]: c = [-45, 6, 0, 72, 1543]In [2]: cOut[2]: [-45, 6, 0, 72, 1543]
They also may store heterogeneous data, that is, data of many different types. For example, the following list contains a student’s first name (a string), last name (a string), grade point average (a float) and graduation year (an int):
['Mary', 'Smith', 3.57, 2022]
You reference a list element by writing ...
Read now
Unlock full access