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

Hello friends, the following code was running correctly few hours ago. Not sure why the error has now occur. Would appreciate any help.

This is the error message:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File " < string> ", line 15, in < module>
TypeError: unsupported operand type(s) for -: ‘list’ and ‘float’

This is the python code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import math

data = IN[0]
k = 0.1999
length = len(data)

Z = []

for i, a in enumerate(data):	
	if (i  < (length-1)):
		z2 = data[i] - k #This is line 15, where error has occur
		d = 20 
		data[i+1] = (d/100) + (z2)

OUT = data

The “import clr” part is not needed here. The issue you get is probably related to your input list.

1 Like

Yeah, the problem was with my input. I wonder, why i didn’t see it. Anyway, Thanks : -)