I need help with def


#1

what is the difference with:

def function(x):
x**2
return x

def function(x):
x**2
print x

Thankyou for your help! i really appreciate it!"


#2

print and return are different things. print will display output in the command line.

return means the function hands something back:

def function(x):
   x**2
   print x

# store returned value in y variable
y = function(3)
print y

#3

Thankyou it really helps!!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.