Basic indexing
Input
IndexableList([10, 20, 30])[1]
Output
20
Index 1 returns the second element, 20.
Full lesson preview
Learn to implement __getitem__ so instances behave like sequences with integer indexing, including negative indices.
Problem statement
Task
Examples
Input
IndexableList([10, 20, 30])[1]
Output
20
Index 1 returns the second element, 20.
Input format
Output format
Constraints
Samples
Input
IndexableList(['x', 'y', 'z'])[0]
Output
x
Returns the first element 'x'. Strings are compared without quotes in the test harness.