View Single Post
Old Aug 6th, 2004, 12:09 PM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 708
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Alright, when you code
def welcome_message(name):
 print name
welcome_message(G.I.Josh)

all it does is print the value, but it doesn't assign it to a variable. For example I'll show you two comparisons of using it and not using it..

>>> def testOne(a):
...     print a
and
>>> def testTwo(a):
...     return a;
Here is what you would get when you run each one.

>>> a = testOne('Hello, World.')
Hello, World.


But that value isn't assigned to a you'll see if you try to print a this happens.


>>> print t
None


You'll see that no value is stored for it. But when you run the second one with the return statement. It does send a value back to the variable as shown.


>>> a = testTwo('Hello, World.')
>>> print a
Hello, World.


Hope that helps. Just know that return passes the value to the variable. Good luck!
thechristelegacy is offline   Reply With Quote