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

Rhodri James rhodri at wildebst.demon.co.uk
Thu Jul 18 19:48:24 EDT 2013


On Fri, 19 Jul 2013 00:04:33 +0100, CTSB01 <scott.moore270 at gmail.com>  
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?

Are you using Python 2.x or 3.x?  That print statement is valid 2.x, but  
"print" is a function in Python 3, so the parameter need parentheses  
around them.

This would all involve a lot less guesswork if you cut and pasted both  
your code and the error traceback.

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list