0
What does return actually do?
I don't understand what return does. A few days ago I read a book about Python but I didn't understand some programs because of return. Please help me :D I hope you understand my question.
2 Antworten
+ 2
Return in a function returns to where the function was called in the execution of the program while sending back a value at the same time.
For example, here we define a function square that returns the square of its parameter, and then we call this function with the value 2. The function returns 4 and this returned value is then printed.
def square(x):
return x*x
print(square(2))
0
Thanks