Introduction
List basics
4. Index out of range
Lists with if statements and loops
Lists in functions
Summary

Instruction

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

Exercise

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.