In [2]:
import numpy as np
x = np.arange(9)

In [3]:
x


Out[3]:
array([0, 1, 2, 3, 4, 5, 6, 7, 8])

In [4]:
x.size


Out[4]:
9

In [14]:
for i in range(15):
    try:
        print(x[i])
    except Exception as e:
        print(e)
    print('haha')


0
haha
1
haha
2
haha
3
haha
4
haha
5
haha
6
haha
7
haha
8
haha
index 9 is out of bounds for axis 0 with size 9
haha
index 10 is out of bounds for axis 0 with size 9
haha
index 11 is out of bounds for axis 0 with size 9
haha
index 12 is out of bounds for axis 0 with size 9
haha
index 13 is out of bounds for axis 0 with size 9
haha
index 14 is out of bounds for axis 0 with size 9
haha

In [ ]: