Python List Indexing & Slicing
Indexing is like house numbers on a street, except computer scientists decided the first house starts at 0! Python also has a superpower: negative numbers count backward from the end, so list[-1] gets the very last item without having to calculate the length.
"Think of slicing a loaf of bread. You can point to the first slice at [0], the crust at the end with [-1], or slice off a section from slice 2 to 4 using [2:5]."
Deep Dive: How It Works
Zero-Based Indexing: The first element is always at index 0, the second at 1, and the nth item at n-1.
Negative Indexing: Python lets you count from right to left using negative numbers. -1 is the last item, -2 is second-to-last, etc.
Slicing Syntax [start:stop:step]: Extracts a portion of the list from index start up to (but not including) index stop.
Omitted slice bounds: [:3] grabs everything from the start up to index 3. [2:] grabs everything from index 2 to the end. [::-1] creates a reversed copy of the entire list!
Syntax Blueprint
items[0] # First item items[-1] # Last item items[1:4] # Slice items from index 1 to 3 items[::-1] # Reverse the entire list
Use square brackets with colons for slicing [start:stop:step].
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Off-by-one errors when slicing: items[0:3] for 4 itemsWhy it happens: Remember that the stop index is exclusive. To get 4 items (0, 1, 2, 3), you need stop index 4.
How to fix: Set the stop index to the desired length (e.g. items[:4]).
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Extract last item with negative indexing
Given scores = [88, 92, 79, 95], use negative indexing to print the last score.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.