- How can I store many values together?
- Explain what a list is.
- Create and index lists of simple values.
- Change the values of individual elements.
- Append values to an existing list.
- Reorder and slice list elements.
- Create and manipulate nested lists.
Alternate video link.
Please use the Jupyter notebook named "04StoringMultipleValuesInLists.ipynb" for this lesson. If you haven't downloaded them already, you may find them here.
[value1, value2, value3, ...] creates a list.
- Lists can contain any Python object, including lists (i.e., list of lists).
- Lists are indexed and sliced with square brackets (e.g.,
list[2:9]), in the same way as strings and arrays.
- Lists are mutable (i.e., their values can be changed in place).
- Strings are immutable (i.e., the characters in them cannot be changed).