+ 1

What's wrong with this 3 lines?

When i define a function like this: def func1(x,y): print(x-2*y) print(func1(6,2)) it gives as output: 2 None My question is, what is this none ans where did it came from?

9th May 2017, 12:23 PM
David Caballero
David Caballero - avatar
4 Antworten
+ 1
func1 does not retun , inside it you print 6-2*2 ,then you print None. Just call func1(6,2) or modify to return x-2*y def func1(x,y): return x-2*y print(func1(6,2)) or def func1(x,y): print(x-2*y) func1(6,2)
9th May 2017, 12:42 PM
Szabó Gábor
Szabó Gábor - avatar
+ 1
I see now! Such a dumb mistake... Thank you so much Szabó!!
9th May 2017, 12:49 PM
David Caballero
David Caballero - avatar
+ 1
I didn't quite mean that AG, I was talking about the "None" output
9th May 2017, 12:50 PM
David Caballero
David Caballero - avatar