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

CTSB01 scott.moore270 at gmail.com
Fri Jul 19 02:25:12 CEST 2013

```On Thursday, July 18, 2013 7:45:49 PM UTC-4, Ian wrote:
> On Thu, Jul 18, 2013 at 5:42 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
>
> > On Thu, Jul 18, 2013 at 5:04 PM, CTSB01 <scott.moore270 at gmail.com> wrote:
>
> >> 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 or 3?  "print" has changed from a statement to
>
> > a function, so the above syntax would be invalid in Python 3.
>
>
>
> Note also that in Python 3 you should change the line "n = n2 / m" to
>
> "n = n2 // m" because the syntax for integer division has also
>
> changed.
>
>
>
> And regardless of your Python version, the last line should probably
>
> be "return rtn", not just "rtn".

Thanks!  I'm using 3.3.2.  As I'm new to this, do you think it's a better idea to jump to 3.3.2 or stick with 2.7?  I, for all intents and purposes, know neither.

```