What is a List?
A list in Python is a built-in data structure used to store a collection of multiple items in a single variable. Lists are defined using square brackets [] with items separated by commas.
Real-world analogy
Multiple Items
Store integers, floats, strings, or even other lists inside one variable.
Zero-Indexed
Every item has a numerical position starting at index 0.
Mutable
You can add, remove, or change elements in a list at any point.
Ordered Sequence
Items maintain their order unless explicitly sorted or re-arranged.
Key vocabulary
- Element / Item โ an individual value stored inside a list.
- Index โ the integer position of an element in the list (starting at 0).
- Mutability โ the ability to alter list contents after creation.
- Length (`len`) โ the total count of elements in a list.
๐งช Compact List Playground
Run the script below to inspect a Python list containing different strings:
๐งช Compact List Playground
Ready to run
No variables yet.
Run your Python code to see them appear here live!
No variables yet.
Run your Python code to see them appear here live!