Re: [Tutor] Function returns 'None'

2010-07-11 Thread Luke Paireepinart
On Jul 11, 2010, at 11:14 AM, Nick Raptis wrote: >> >> >> > > Also, another preference of mine, would you be kind enough to answer to the > list and cc the original poster if you can? Doing it the other way around > breaks my (quite stupid I admit) filters, and perhaps others' too. That's t

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 06:50 PM, Luke Paireepinart wrote: I think the new version is harder to understand. Sent from my iPhone On Jul 11, 2010, at 10:43 AM, Nick Raptis wrote: Aww! A critic! You humble me (really, I'm not being sarcastic here, I welcome it gladly) I won't argue about it, though. If

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Luke Paireepinart
I think the new version is harder to understand. Sent from my iPhone On Jul 11, 2010, at 10:43 AM, Nick Raptis wrote: > On 07/11/2010 06:28 PM, Nick Raptis wrote: >> >> def recursfac(x,carryover=1): >>print 'x:',x,'carryover:', carryover >>if x > 1: >>carryover *= x >>c

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 06:28 PM, Nick Raptis wrote: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x carryover = recursfac(x-1, carryover) return carryover And this returns x: 3 carryover: 1 x: 2 carryover: 3 x: 1 carryover: 6 6 Don

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Nick Raptis
On 07/11/2010 04:59 PM, Dominik Danter wrote: Hello As en exercise I wrote the following function: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) else: return carryover print recursfac(3

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Alan Gauld
"Dominik Danter" wrote def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) No return value here so when the reursed function returns carryover we have nowhere to go in the calling function so we return

Re: [Tutor] Function returns 'None'

2010-07-11 Thread Adam Bark
On 11/07/10 14:59, Dominik Danter wrote: Hello As en exercise I wrote the following function: def recursfac(x,carryover=1): print 'x:',x,'carryover:', carryover if x > 1: carryover *= x recursfac(x-1, carryover) else: return carryover print recursfac(3) Ve