Caroline Studdart Caroline Studdart - 1 year ago 65
Python Question

Getting "TypeError: unsupported operand type(s) for -: 'list' and 'list'"

Hi I know there are a few people that had this issue but none of the solutions I've seen are helping. I'm taking a set of data, reading the file then creating arrays from the data to input into this equation:

Dist = 10 ** ((app_m - abs_M + 5.) /5)

Where I app_m and abs_M are the arrays from the data.

I'm using Python 2.7 and only just learning so if things can be explained as simply as possible that would be great

Answer Source

I eventually solved this with

 Dist = []
for i in range(len(app_m)):
    Dist.append((float(app_m[i]) - float(abs_M[i]) + 5.)/5)