Step: Lists: slicing

Lists: slicing

A slice list[start:stop] returns a new list from start up to (but not including) stop.

Why it matters: slicing is the standard way to grab a sub-range without a manual loop.

Example: [10, 20, 30, 40][1:3] is [20, 30].

Your turn: slice out the middle three numbers (indices 1 through 3) with numbers[1:4].

Pitfall: the stop index is exclusive — [1:4] gives you indices 1, 2, 3, not 4.

Setup:
numbers = [10, 20, 30, 40, 50, 60]
Your code:
Expected output:
[20, 30, 40]
Step 4 of 18