A Python list keeps values in order and lets you access each value by its position. Understanding how the positions change helps prevent mistakes when a program edits the list.
Worked example
Begin with the values apple, pear, and plum. Their positions are zero, one, and two. Removing the pear moves plum to position one. The list still has an order, but a position identifies a location in the current list rather than a permanent identity for an item.
What to check
Write the list after each operation before running a short program. Check an empty list and a position at the end. Removing items while iterating over the same list can skip values because later items move. A clear alternative is to build a new list containing the values you want to keep. Predict its contents and then compare the prediction with the program’s output.
Continue with the book
Explore the full treatment, worked examples, and exercises in Code Quest with Python.
Companion article for Code Quest with Python, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
