0
Plis help.
what does returning from a function actually meant. elaborate with examples
2 Answers
+ 1
When you create a typical function you would generally say if it'll return something or will it simple just do something. If a function returns something then we can store that something in something else like a variable.
def give_back(num):
return num
var = give_back(3)
Our variable that goes by the name "var" now has the value of 3. Our function gave back to us, it's *fruitful*.
def print_text(text):
print(text)
print_text("Some text")
# Would print to screen:
# Some text
That function doesn't give back it just...does something. All functions give back something though, *fruitful functions* will return something for us to use, hence *return*. While the other functions are void. They do something but doesn't return a value, well that function actually returns a value of None which is...nothing lol.
0
thats not how you spell please matey xx