Re: [Tutor] function question

2019-01-05 Thread Steven D'Aprano
Hello David, and welcome! On Sat, Jan 05, 2019 at 11:18:04AM -0500, David Lynch wrote: [...] > From what I've read about functions I should be able to define a function > with 2 variables? And then I can add all of my code into that function by > indenting it. So far so good! Here's an example

Re: [Tutor] function question

2019-01-05 Thread Alan Gauld via Tutor
On 05/01/2019 16:18, David Lynch wrote: > Hello, > I'm not sure if this is where I can find this sort of help but I am > struggling understanding functions. I have written a simple math code but I > feel like it could be improved if I were to use it in a function. You arein the right place and

[Tutor] function question

2019-01-05 Thread David Lynch
Hello, I'm not sure if this is where I can find this sort of help but I am struggling understanding functions. I have written a simple math code but I feel like it could be improved if I were to use it in a function. >From what I've read about functions I should be able to define a function with

Re: [Tutor] Function question

2017-04-01 Thread Peter O'Doherty
On 25-03-17 11:17, Alan Gauld via Tutor wrote: method: print(' '.join(anotherFunction(4)) Many thanks! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Function question

2017-04-01 Thread Peter O'Doherty
Many thanks! On 25-03-17 11:17, Alan Gauld via Tutor wrote: On 25/03/17 10:01, Peter O'Doherty wrote: def myFunc(num): for i in range(num): print(i) print(myFunc(4)) 0 1 2 3 None #why None here? Because your function does not have an explicit return value so Python returns

Re: [Tutor] Function question

2017-03-25 Thread Sri Kavi
On Sat, Mar 25, 2017 at 3:31 PM, Peter O'Doherty wrote: > > def myFunc(num): > for i in range(num): > print(i) > > print(myFunc(4)) > 0 > 1 > 2 > 3 > None #why None here? > > Because there are two print() functions, one inside the function and another outside. When a function does

Re: [Tutor] Function question

2017-03-25 Thread Alan Gauld via Tutor
On 25/03/17 10:01, Peter O'Doherty wrote: > def myFunc(num): > for i in range(num): > print(i) > > print(myFunc(4)) > 0 > 1 > 2 > 3 > None #why None here? Because your function does not have an explicit return value so Python returns its default value - None. So the print() inside

[Tutor] Function question

2017-03-25 Thread Peter O'Doherty
Hi, Apologies for the very basic question but could anyone explain the behaviour of these two functions (in Python3.5)? def myFunc(num): for i in range(num): print(i) print(myFunc(4)) 0 1 2 3 None #why None here? def myFunc(num): for i in range(num): return i