In the following code (derived from code written by [dmh126](https://gis.stackexchange.com/a/163010/2856)) I want to classify .tif file based on it's pixel values after converting it into an array. I think there is some mistake in for loop which is giving me an error "IndexError: index 101 is out of bounds for axis 0 with size 101". I am posting my code here.

```
from osgeo import gdal
import numpy as np
driver = gdal.GetDriverByName( 'GTiff')
file = gdal.Open( 'Gadchiroli.tif')
band = file.GetRasterBand(1)
lista = band.ReadAsArray(0,0,file.RasterXSize,file.RasterYSize).astype(np.int)
print(lista)
print(range(file.RasterXSize))
print(range(file.RasterYSize))

# reclassification
for j in range(file.RasterXSize-1):
    s=lista[j]
    print(s)
    i=0
    #print(j,end='')
    for i in  range(file.RasterYSize-1):
        print(i,j,end='')
        if s[i] < 280:
           print(s[i])
           lista[i,j] = 1
        elif 280 < s[i]< 290:          
            lista[i,j] = 2
        elif 290 < s[i] < 300:
            lista[i,j] = 3
        elif 300 < s[i] < 310:
            lista[i,j] = 4
        elif 310 < s[i] < 320:
          #print(s[i])
            lista[i,j] = 5
        elif 320 < s[i] < 330:
            lista[i,j] = 6
       # print(s[i])
        else:
            lista[i,j] = 7

# create new file
file2 = driver.Create( 'class.tif', file.RasterXSize , file.RasterYSize , 1)
file2.GetRasterBand(1).WriteArray(lista)

# spatial ref system
proj = file.GetProjection()
georef = file.GetGeoTransform()
file2.SetProjection(proj)
file2.SetGeoTransform(georef)
file2.FlushCache()

```