Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
List basics
4. Index out of range
Lists with if statements and loops
Lists in functions


Great! Now, let's perform a simple experiment: what happens when you try to print an element that is not available in the list?


As you can see in the template code, there are six elements in the list, but we're trying to access companies[6] (i.e. the seventh element, which does not exist). Run the code.

Note that we get an error: list index out of range. You need to be careful with the indices!

Click Next exercise to continue.