When should we use return statement in functions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

When should we use return statement in functions

Hey I just started to learn python but I don’t when i should use the print or return statement

26th May 2020, 6:09 AM
Bilal
1 Answer
+ 2
When you want to assign a variable you have to use return.... And note that never assign a variable to the function that is printing anything... Because that variable will become equal to None... According to me you should always use return statement while making a complex program... As you can assign a variable with the variable that is returned by the function and you can use it later on...
26th May 2020, 6:16 AM
Namit Jain
Namit Jain - avatar