Replace this line with your code.
what it says, it returns something (it hands you something back), we can see this:
def example(x,y): return x * y answer = example(5,3) print example
in the code above, the result of the multiplication is handed back by the function, an stored in answer.
Was just thinking printing the value was more useful as I could see the result, as opposed to just returning the value and the console really doesn't show anything and one is stuck wondering whether the code is right or not.
Thanks for the explanation. Appreciate it.
yea, but once you advance through the course you will see the value of return more
you could also modify the above code a bit:
def example(x,y): return x * y print example(5,3)
just add a print statement in front of the function call, this will print the returned result. Return is very useful. one important thing of return is that the function ends the moment a return keyword is reached.
The last point is an important one to keep in mind:)
Appreciate the help. Thanks.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.