+ 1

Why do i need for function "return"?

I do the test about this function but i don't mean what do it do

9th Jul 2020, 11:19 PM
Лёша Мяло
Лёша Мяло - avatar
4 Answers
+ 3
Return I assume you mean. Return will return whatever you tell it to. in a function for example, it can return a string or integer then that will go back to wherever the function was called from and stored in a variable or printed. it also exits out a function when its called so it should come at the end of a function.
9th Jul 2020, 11:27 PM
John Dem
John Dem - avatar
+ 3
Here is another example def question(x,y): return f'the answer is {x*y}' print(question(2,4))
10th Jul 2020, 1:48 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
You can call functions anywhere in your code when you do this you pass an argument to the function the function will do somthing with the value and then return somthing back to were you called it. It's asking a question.. its read by somone and then information is sent back to the same place it was asked.
9th Jul 2020, 11:31 PM
D_Stark
D_Stark - avatar