Sequences
Many programs are written to process collections of data. Sequences are one of the most common collection data types in Python. This group include lists, tuples, and ranges. Sequences are ordered, meaning their elements can be accessed by index.
Some sequences are mutable, meaning they can grow and shrink. Lists in Python are mutable sequences.
Some sequences are immutable, meaning they cannot be modified once created. This group includes tuples and ranges.
Sequences are iterables, that is, you can loop over them to process each item individually.
At the end of this lesson, you will be able to:
- create lists, tuples and ranges
- mutate lists using the
listtype methods - slice sequences
- iterate sequences
- write simple list comprehensions