Why does it say my list index is out of range?


#1

Question

Why does it say my list index is out of range?

Answer

If you see an error that reads IndexError: list index out of range, this means you’ve tried accessing an index that the list doesn’t have an element at!
If you wrote print numbers[1 + 3], for example, you would be effectively trying to access index 4, or the 5th item, in a list that only has 4 items! To add the values like we want to for this exercise, simply separate them on their own, like this: print numbers[first] + numbers[second]