Getting IndexError : list indexout of range in python

2 weeks ago 14
ARTICLE AD BOX

Error I am getting:

IndexError: list index out of range

My code:

number = [1, 2, 3] print(number[5])

What I expected:

I expected it to print the element at index 5.

What actually happened:

Python showed IndexError: list index out of range.

What I tried:

I checked my list.

I tried printing other indexes.

I still couldn't understand why this error happens.

Question:

Why is this error happening, and how can I fix it?

Read Entire Article