Python Foundations · Lesson 8 of 12Lists and indexing
List creation, traversal and updating. Learn through short examples, practical tasks and targeted questions.
← All lessons
Working with lists
A list groups related values in an ordered sequence. The first element has index 0; loops can visit each element to total values, search for a match or update the contents. Trace the index and value separately when using a counted loop.
Watch out: The final valid index is len(items)-1. Attempting items[len(items)] raises an IndexError.
A free TutorSyntax programming lesson. About our teaching approach.
APPLY THE IDEA
Use this skill beyond the example
Indexes start at zero in Python. When tracing a list operation, write the index above each item and note whether a method changes the original list or produces a new value.
Quick check: What does items[-1] access?
Check: The last element in the list, provided the list is not empty.
Continue with related practice →