## ghostDoctor 3 years ago Question re: PS2, Problem One My solution to this problem ended up being similar to the given solution, except instead of iterating the for loop through range(0,len(poly)), I choose to iterate directly through "poly". However, this threw an error: "tuple indices must be integers". My plan was that "for i in poly" would go through each indice in the tuple and assign that particular "i" the value of that indice. I had set up the code to multiply the value of poly[i] by x and then raise it to the value of the indice represented by "i". I didn't think I was modifying the value of the indice

• This Question is Open
1. snark

it seems to be saying that you are looking for element tuple[1.5], a fractional index into the tuple. without seeing any code, it's only a guess.

2. ghostDoctor

My code was: def evaluate(poly, x): for i in poly: print i sum =+ ((poly[i]*x)*i) print sum and then the value of "poly" was whatever the problem indicated it was, a bunch of floats. i think i assumed that "i" would take the indice value of the tuple, rather than the actual value at that indice.

3. harsimran_hs4

what you are doing is perhaps picking up the index and multiplying it by x and the multiplying this product further by the power of x the wrong part is that the value of poly[i] i.e eg 3x2 so in your solution even 3 is getting raised to the power perhaps you should do something like poly[i] * (x**i) well i don`t explain perfectly anything unclear please do ask... i hope this helps!