Showing posts with the label Python - Return Statement

Python Programming Language - Return Statement

Returning the result The function can return a result. To do this, the function uses the return operator, followed by the return value: def function_name ([parameters]):     instructions     return return_value Let's define the simplest function that returns a value: def get_message():     return "Hello world" Here, after the operator return there is a line "Hello World" - this is the value the function will return get_message(). This function result can then be assigned to a variable or used as a normal value: def get_message():     return "Hello World"   # get the result of the get_message function into the message variable message = get_message() print(message) # Hello World   # you can directly pass the result to the get_message function print(get_message()) # Hello World After the return statement there can also be a complex calculated expression, the result of which will be returned from the function. For example, let's define a functio