← Dictionary
Code·basic

List

An ordered collection of values. Python's name for what some languages call an array.

A list holds multiple values in order.

colors = ["red", "green", "blue"]
numbers = [1, 2, 3, 4, 5]
mixed = ["Stella", 18, True]

You access items by position, starting at zero: colors[0] is "red", colors[1] is "green".

Lists are the workhorse of programming. The lines of a file. The students in a class. The steps in a recipe. Anything where you have many of the same kind of thing.

Related