Search⌘ K

Sequences

Explore the concept of sequences in Python, understanding ordered collections like lists, strings, and tuples. Learn the difference between mutable and immutable sequences, how to use indexing for random access, and how sequences support iteration and lazy evaluation. Gain clarity on how sequences relate to iterators and the significance of range as a lazy immutable sequence.

What are sequences?

A sequence is an ordered collection of items that allows random access. Examples of sequences include lists, strings, and tuples. You should already be familiar with these, but here is how they relate to iterators:

Ordered means ...