Anuj Anuj - 4 months ago 15
Python Question

How to evaluate an expression in for loop using Python?

I want to evaluate an expression inside for loop. I am doing:

for i in range(0,255):
Q[i+1,1] = (np.floor_divide(i, q) * q + q/2)

but this returns an error saying

IndexError: index 1 is out of bounds for axis 1 with size 1".


The size is 256x1 but still you have to index with starting at 0. So you need Q[i,0]