Does return do the same function as print does?


#1

Does return do the same function as print does?


FAQ: Learn Python - Functions - Practice Makes Perfect
FAQ: Learn Python - Functions - Practice Makes Perfect
#2

No, having two keywords which do the same thing wouldn’t be very practical.

return does what it says, handing something back:

def example():
   return "hello world"

# store returned result in variable
x = example()

# now lets print the returned result
# which we captured in x
print x