The Power of Lists
You will now look at the first type of data structure in Python: lists.
A list is a type of container in Python that is used to store multiple data sets at the same time. Python lists are often compared to arrays in other programming languages, but they do a lot more.
A list in Python is written within square brackets, [ ]
. Each element in the list has its own distinct position and index. The elements in a list have a finite sequence. Like other programming languages, the index of the first item of a list is 0, and the second item has an index of 1, and so on. This has to do with how lists are implemented at a lower programming level, so do take note of this when you are writing index-based operations for lists and other iterable objects.
You will now look at the different ways that lists can be useful by completing Exercise 21, Working with Python Lists.