[Solved] TypeError: ‘float’ object cannot be interpreted as an index, how to solve it?


can you write in your question an example of what the values of pts[0], pts[1], pts[2] looks like?

if the values are close to integers (like 1.00004 or 3.9998) you can use the round function to round the values to the nearest integer like:

data = array(data, 'f').reshape(round(pts[2]), round(pts[1]), round(pts[0]))

solved TypeError: ‘float’ object cannot be interpreted as an index, how to solve it?