- HowTo
- Python How-To's
- Check if Index Exists in Python List
Check if Index Exists in Python List
Python Python List
Created: October-19, 2021 | Updated: December-25, 2021
We will introduce two methods to check if a list index exists using the list range and the IndexError exception.
Check if Index Exists in Python List Using the List Range
We will have to check if the index exists in the range of 0 and the length of the list.
fruit_list = ['Apple','Banana','Pineapple'] for index in range[0,5]: if 0