In Python, a list is a data type (its documentation is available here, that could be used to store elements in a sequence.

The topics discussed in this chapter can be difficult to grasp unless used in practice. Any example that is represented using this notation: >>> indicates that it could be tested using the Python interpreter.

A list may consist of strings, objects (discussed in detail in this chapter) or numbers, and so on. For instance, the following are examples of lists:

    >>> sequence = [1, 2, 3, 4, 5, 6]    >>> example_list = ['apple', 'orange', 1.0, 2.0, 3]

In the preceding set of examples, the sequence list consists of numbers between 1 and 6 while the example_list

Get Python Programming with Raspberry Pi now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.