Step: Lists: indexing
Lists: indexing
Lists are indexed from 0, and negative indices count from the end — -1 is the last item.
Why it matters: -1/-2 are the idiomatic way to grab the end of a list without knowing its length.
Example: for [10, 20, 30], [0] is 10 and [-1] is 30.
Your turn: print the first and last fruit (fruits[0] and fruits[-1]), separated by print's default space.
Pitfall: indexing past the end (fruits[4]) raises IndexError — Python doesn't silently return None.
Setup:
Your code:Expected output:
Step 3 of 18