Stockertim Dictionary · Technology
Python list
Also called list in Python, list indexing, Python list index
In short
An ordered, changeable collection of values in Python, written in square brackets and separated by commas, whose items are reached by position counting from zero.
- Beginner
- Concept
- Checked
In detail
A list holds several values in order under one name. sales = [120, 95, 140, 110] creates a list of four numbers. Items are reached by their index, which starts at zero, so sales[0] is 120 and sales[3] is 110. Negative indexes count from the end, so sales[-1] is also 110.
Lists are mutable: they can be changed after they are made. sales.append(130) adds an item to the end, sales[1] = 100 replaces the second item, and len(sales) gives the number of items. A slice such as sales[1:3] returns a new list from index 1 up to but not including index 3, which here is the second and third items.
A list can hold any mix of types, including other lists, although in practice a list usually holds one kind of thing. Built-in functions work on lists of numbers directly: sum(sales), min(sales), max(sales) and sorted(sales). A for loop visits each item in order, which is how most processing of a list is written.
Zero-based counting is the main source of mistakes. The fifth item is at index 4, asking for sales[4] on a four-item list raises an IndexError, and slices that stop one short of the intended end drop an item. Another trap is copying: writing b = a makes both names refer to the same list, so changing b also changes a; a.copy() makes a separate list.
Worked example
A market trader in Kumasi records the takings of five days in a list.
takings = [300, 450, 400, 350, 500]takings[0]is 300 (Monday) andtakings[4]is 500 (Friday).sum(takings)gives 300 + 450 + 400 + 350 + 500 = 2,000, and the daily average is 2,000 / 5 = 400.
Five days of takings are handled under one name, and the totals are calculated in two short lines.
In practice
Analysts use lists for short sequences such as file names to process, column names to keep, or the months of a year to loop over. For large tables of data they usually move to a pandas DataFrame, which is built for column-wise work, but lists remain the everyday glue of a script.
Watch out
- Indexes start at zero, so the nth item is at position n − 1; this is a common source of off-by-one errors.
- Assigning one list to a new name does not copy it; both names change together.
Learn it properly
Official sources
- Quality assurance of code for analysis and research · Government Analysis Function
Facts last checked on 9 November 2026.
Education, not advice: the Stockertim Dictionary explains what terms mean. It never recommends buying or selling anything.