items []
Try it yourself →Creates an ordered collection of values.
Syntax
name = [element1, element2, ...]
Description
A list is created with square brackets. Elements are accessed with an index starting at 0; a negative index counts from the end.
Returns
A list object.
Example
colors = ["red", "purple", "green"] print(colors[0]) print(colors[-1])
Expected output
red green
When to use?
Holding multiple values (names, scores, products) in a single variable.
Common mistakes
- ⚠️ Indexing starts from 0, not 1: the first element is items[0].