What Python data structure is ordered, mutable, and allows duplicate elements?

The story behind the answer

A Python list is an ordered, mutable data structure that allows duplicate elements.

Lists are one of Python’s most widely used collection types. They preserve insertion order, so items can be accessed by position, starting with index 0. Because lists are mutable, programs can add, remove, replace, or reorder elements after creation—for example, with append(), remove(), or sort(). A list can also contain repeated values, such as ["red", "red", "blue"].

The main mix-up is with tuples: tuples are ordered and allow duplicates, but they are immutable. Sets are mutable and automatically remove duplicate elements, but they are designed for membership testing rather than positional order. Dictionaries store key-value pairs; modern Python preserves dictionary insertion order, but a dictionary is not the ordinary answer to a question describing a sequence of elements.

Python lists use square brackets, while tuples commonly use parentheses: [1, 2, 2] versus (1, 2, 2). Lists can even hold different object types, including nested lists, making them useful for everything from simple sequences to tables and stacks.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: