hi can someone pls explain the return command in detail for me with an example that will simplify it for me pls i need to understand the return command to be able to write a good function code
When a function reaches a return statement, it ends the function. A return statement can specify a value to return from the function. If no value is specified, the value None will be returned. More than one return statement can be in a function, but the function ends the first time a return statement is executed. >>> def tf( bool ): ... if( bool ): ... return True ... return ... >>> if( tf( True ) ): ... print "Hello World" ... else: ... print "Goodbye World" ... Hello World >>> if( tf( False ) ): ... print "Hello World" ... else: ... print "Goodbye World" ... Goodbye World >>>
tnx for the well detailed explanation just what i needed
You're very welcome!
Join our real-time social learning platform and learn together with your friends!