Re: Function passed as an argument returns none

2014-10-02 Thread Steven D'Aprano
Chris Angelico wrote: On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody rustompm...@gmail.com wrote: So by now you know there are 2 kinds of return: So the morals in short: 1. Stick to the return that works -- python's return statement -- and avoid the return that seems to work -- the print

Re: Function passed as an argument returns none

2014-10-02 Thread Shiva
Hi All, Thank you everyone. This is fantastic - I post a query and go to sleep and by the time I get up there is already a nice little thread of discussion going on. By the way, I sorted it with all your suggestions. def donuts(count): if count = 9: #This had to be 9 instead of 5 as

Re: Function passed as an argument returns none

2014-10-02 Thread Chris Angelico
On Thu, Oct 2, 2014 at 6:46 PM, Shiva shivaji...@yahoo.com.dmarc.invalid wrote: Hi All, Thank you everyone. This is fantastic - I post a query and go to sleep and by the time I get up there is already a nice little thread of discussion going on. Yeah, that's what python-list is like!

Re: Function passed as an argument returns none

2014-10-02 Thread cl
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: between printing output to the screen and returning values from a function, and under what circumstances Python will automatically print said returned values as a convenience. Conflating the two as 2 kinds of return is an To me

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Thursday, October 2, 2014 3:18:22 PM UTC+5:30, wrote: Steven D'Aprano wrote: between printing output to the screen and returning values from a function, and under what circumstances Python will automatically print said returned values as a convenience. Conflating the two as 2 kinds of

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Thursday, October 2, 2014 1:30:03 PM UTC+5:30, Steven D'Aprano wrote: Chris Angelico wrote: wrote: So by now you know there are 2 kinds of return: So the morals in short: 1. Stick to the return that works -- python's return statement -- and avoid the return that seems to work -- the

Re: Function passed as an argument returns none

2014-10-02 Thread Steven D'Aprano
Rustom Mody wrote: On Thursday, October 2, 2014 1:30:03 PM UTC+5:30, Steven D'Aprano wrote: Chris Angelico wrote: Restoring the attribution line you removed: On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody rustompm...@gmail.com wrote: So by now you know there are 2 kinds of return: So the

Re: Function passed as an argument returns none

2014-10-02 Thread Rustom Mody
On Friday, October 3, 2014 5:41:12 AM UTC+5:30, Steven D'Aprano wrote: [Rustom] Right and the OP subject as well as post are essentially that conflation: [allegedly Steven] Any idea why 'None' is getting passed even though calling the donuts(4) alone returns the expected value? I didn't

Re: Function passed as an argument returns none

2014-10-02 Thread Chris Angelico
On Fri, Oct 3, 2014 at 11:49 AM, Rustom Mody rustompm...@gmail.com wrote: Ok so there is no conventional attribution line because it was cut-pasted from elsewhere in the thread but there is a clear and unequivocal prefix of OP subject as well as post. When I respond to this part... Why/how

Function passed as an argument returns none

2014-10-01 Thread Shiva
Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count = 5: print('Number of donuts: ',count) else: print('Number of donuts: many') return It works fine if I call donuts(5) It

Re: Function passed as an argument returns none

2014-10-01 Thread Andrew Berg
On 2014.10.01 17:37, Shiva wrote: Only 'None' gets passed on to parameter 'got' instead of the expected value of 4. Any idea why 'None' is getting passed even though calling the donuts(4) alone returns the expected value? donuts() prints what you tell it to (Number of donuts: 5), and then

Re: Function passed as an argument returns none

2014-10-01 Thread Chris Kaynor
Chris On Wed, Oct 1, 2014 at 3:37 PM, Shiva shivaji...@yahoo.com.dmarc.invalid wrote: Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count = 5: print('Number of donuts: ',count)

Re: Function passed as an argument returns none

2014-10-01 Thread Mark Lawrence
On 01/10/2014 23:37, Shiva wrote: Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count = 5: print('Number of donuts: ',count) else: print('Number of donuts: many') return It

Re: Function passed as an argument returns none

2014-10-01 Thread Denis McMahon
On Wed, 01 Oct 2014 22:37:13 +, Shiva wrote: Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count = 5: print('Number of donuts: ',count) else: print('Number of donuts:

Re: Function passed as an argument returns none

2014-10-01 Thread Rustom Mody
On Thursday, October 2, 2014 4:07:44 AM UTC+5:30, Shiva wrote: Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count = 5: print('Number of donuts: ',count) else: print('Number of

Re: Function passed as an argument returns none

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody rustompm...@gmail.com wrote: So by now you know there are 2 kinds of return: So the morals in short: 1. Stick to the return that works -- python's return statement -- and avoid the return that seems to work -- the print statement Please. There