On 6/21/2012 10:42 PM, Xander Solis wrote:
> Hello Python list,
> 
> Noob here with a newbie question. I'm reading and working on the
> exercise of the book, Learn Python the Hard way 2.0. When I use this
> code, I get "None" on the output. My question is why does this happen?
Your function prints the number and then returns None (you have no
return statement in the function to change this) to the print statement.
If you want to have the function return a value, use the return
statement instead of print inside the function:

def func(some_value):
  return some_value
x = func(5)
print x

will print 5.

-- 
CPython 3.3.0a4 | Windows NT 6.1.7601.17803
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to