Creating a Program to Decompose a Number and Run a Function on that Decomposition

Dave Angel davea at davea.name
Fri Jul 19 01:49:19 CEST 2013


On 07/18/2013 07:04 PM, CTSB01 wrote:
> On Thursday, July 18, 2013 6:49:03 PM UTC-4, Ian wrote:
>> On Jul 18, 2013 4:23 PM, "CTSB01" <scott.m... at gmail.com> wrote:
>>
>>>
>>
>>>    File "<pyshell#9>", line 2
>>
>>>      ...   rtn = []
>>
>>>      ^
>>
>> The "..." is the continuation prompt from the interactive interpreter, not part of the code. Don't paste it into Python.
>
> Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid syntax' issue unfortunately.
>
>>> def phi_m(x,m):
>        rtn = []
>        for n2 in range(0, len(x)*m - 2):
>          n = n2 / m
>          r = n2 - n * m
>          rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
>          print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
>        rtn
>
> on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is it something obvious?
>

It's only obvious if you're using Python 3.x.  You have forgotten the 
parentheses in the call to the print() function.

On the other hand, if this is Python 2.x, I have no idea.  Next time, 
please paste the actual error, not paraphrased.  The error message 
includes a traceback. and a pointer to where in the line the error was 
detected.  If it's pointing at the end of the second token, you must be 
running Python 3.x

And since you're using that annoying googlegroups, see this:

http://wiki.python.org/moin/GoogleGroupsPython




-- 
DaveA




More information about the Python-list mailing list