[Edit]
+
0
-
0
python check if list index exists
1 2 3 4 5 6 7 8 9 10 11my_list = ['A', 'B', None, 1, 2] searchIndex = 5 if searchIndex < 0 or searchIndex > len(my_list) - 1: print("Index doesn't exist.") else: print('Index exists.') # Output: # Index doesn't exist.