June 2025
Beginner to intermediate
473 pages
13h 30m
English
With lists, Python offers an immensely flexible language construct for managing larger volumes of data. Lists are formulated in square brackets. Lists can hold elements of any data type. The elements in a list can be accessed in the same way as the characters of a string by “slicing,” that is, with list[start:end]. In addition, Python provides countless functions and methods for processing lists.
>>> lst = [1, 2.3, 'abc', 'efg', 12]>>> lst[2] # the third element 'abc'>>> lst[2:4] # from the third to the fourth element ['abc', 'efg']>>> lst[::-1] # reverse order [12, 'efg', 'abc', 2.3, 1]>>> lst[0] = 3 # changes the first list element>>> lst [3, 2.3, 'abc', 'efg', 12]
Since any Python object is allowed as a list element, nested ...
Read now
Unlock full access