+5

What does the return statement in python do

8/21/2019 10:07:42 PM

Viksta

8 Answers

New Answer

+5

It returns a value such that when the function is called, the value is returned.

+4

In simple explanation return is used in python to exit or terminate a function and return a value. In example if you use def myfunction():   return 3+3   print("Hello, World!") print(myfunction()) We call the function myfunction() And you will notice that it only print the return value 6 and terminate there. It'll not print the remaining code after return.

+3

And returns program flow to the point just after where the function was called from.

+3

Even if you don't use "return" a None-Type object is returned by default.

+2

Frankly it does exactly what it does in any other programming language, which is exit a subroutine or a main program. it may or may not return a value which could be a number or a list of values or a string. ☀️☀️

+2

Return statement just gives the result of the input of that function called for. And that returned value can be stored in a variable for future reference(to use some where else) in the program. or you can directly print.

+1

it calls the function

+1

It returns the valur of the function