I'm Solving the Problem set of MIT's introduction to programming.
def compute_deriv(poly):
"""
Computes and returns the derivative of a polynomial function. If the
derivative is 0, returns (0.0,).
"""
der = ()
for ele in poly :
if poly.index(ele) == 0 :
continue
else:
der += tuple(ele*float(poly.index(ele)))
return der
poly = (-13.39, 0.0, 17.5, 3.0, 1.0) # x^4 + 3x^3 + 17.5x^2 - 13.39
print compute_deriv(poly)
why the program is trying to iterate over this line? and return the error not iterable? it shouldn't be so
der += tuple(ele*float(poly.index(ele)))