Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction to nested lists
4. Non-rectangular nested lists
Iterating over nested lists
Modifying nested lists
Working with multiple lists
Summary

Instruction

Good job! In Python, nested lists do not need to store the same number of elements. For example:

donations = [
  [345.0, 287.80, 119.27, 329.30],
  [294.25, 349.0, 178.90],
  [401.0, 456.45, 289.43, 319.27]
]

The above example has only three fundraising results in the second list, as opposed to four in the other two lists. This is perfectly fine in Python. Just be careful with the indexes: there is no "fourth" element in the second list, so invoking donations[1][3] will produce an error.

Exercise

We've removed the 2nd and 3rd prize winners from the third nested list in hackathon_results. Try to access one of these elements and see what happens.

As you can see, an IndexError is thrown.

When you're done experimenting, click I'm done. Next exercise.