Difference between Return and Print


#1



Replace this line with your code.


#2

return hands something back:

def example():
     return 5

x = example()
print x

print just prints something, return means the function will hand something back, which you can store in a variabl


#3

Print Vs Return---

Print()
It is a function.
Every function contains return construct . When It has nothing to return ,It returns None.
None is a special object that is supposed to represent the absence of any real thing.
.......................................................................................................................................................................

Return
It is a control flow construct that is used inside a function. It acts like an agent that takes processed data from function and provide it to any part of a program.

Few links to dig dipper:
Wikipedia
StackExchange

So function ( here it is print() ) is like a boss and return is a employe working under function who goes on errands when function asks too. :slight_smile:


#4

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