Python lists, such as those returned by the string split() method, are sequences of objects. Unlike strings lists are mutable, insofar as the elements within them can be replaced or removed, and new elements can be inserted or appended. lists are the workhorse of Python data structures.
Literal lists are delimited by square brackets, and the items within the list are separated by commas. Here is a list of three numbers:
>>> [1, 9, 8]
[1, 9, 8]
And here is a list of three strings:
>>> a = ["apple", "orange", "pear"]
We can retrieve elements by using square brackets with a zero-based index:
>>> a[1]
"orange"
We can replace elements by assigning to a specific element:
>>> a[1] = 7
>>> a
['apple', 7, 'pear']
See how lists can be heterogeneous with...