<p dir="ltr"><br>
On 19 Jul 2013 03:24, "CTSB01" <<a href="mailto:scott.moore270@gmail.com">scott.moore270@gmail.com</a>> wrote:<br>
><br>
> Thanks for the alternative links, I'll use <a href="http://gmane.org">gmane.org</a> as an access point next time.<br>
><br>
> ><br>
> > Don't paraphrase.  Just copy/paste it into your email message.  And I'm<br>
> ><br>
> > assuming you know to run things from the terminal window, and not from<br>
> ><br>
> > IDLE or something else that messes up the error messages.  Your comment<br>
> ><br>
> > about 'orange' doesn't sound promising.<br>
> ><br>
> ><br>
> ><br>
> > As Ian pointed out, you have no return value in this function.  You<br>
> ><br>
> > calculate something called 'rtn', but never use it.  The last line<br>
> ><br>
> > accomplishes nothing, since rtn is neither assigned nor returned, nor<br>
> ><br>
> > passed nor...   You probably wanted:<br>
> ><br>
> ><br>
> ><br>
> >        return  rtn<br>
> ><br>
><br>
> Does something like<br>
><br>
> def phi_m(x, m):<br>
>           rtn = []<br>
>           for n2 in range(0, len(x) * m - 2):<br>
>             n = n2 / m<br>
>             r = n2 - n * m<br>
>             rtn.append(m * x[n] + r * (x[n + 1] - x[n]))<br>
>             print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)<br>
>           return rtn<br>
><br>
> look right?<br>
><br>
> It doesn't seem to have any errors.  However, I do receive the following error when trying to implement an x after having defined phi:<br>
><br>
> >>> x = [0, 1, 1, 2, 3]<br>
> >>> phi_m(x, 2)<br>
> Traceback (most recent call last):<br>
>   File "<pyshell#6>", line 1, in <module><br>
>     phi_m(x, 2)<br>
>   File "<pyshell#2>", line 6, in phi_m<br>
>     rtn.append(m * x[n] + r * (x[n + 1] - x[n]))<br>
> TypeError: list indices must be integers, not float</p>
<p dir="ltr">When you think about it, it makes sense. If you have a list, say,</p>
<p dir="ltr">[2, 5, 1]</p>
<p dir="ltr">You can say, I want the first item (0) or the third item(2) but never, the one-and-a-halfeth (0.5) item. Python only accepts integer values when accessing list items.</p>
<p dir="ltr">To access list items, convert your index into an integer value.</p>