+ 1
why the return is not working in function
if we replace that print(password) with return password it is showing no output why? https://code.sololearn.com/cSECQypdRRHd/?ref=app
4 Answers
+ 2
Return fucntion works but not that anything after the return statement won't be executed
+ 2
It is working, this type of return is not like Jupyter, you will still need to print it, or pass it into another function to use it.
###
pword=mypassword()
print(pword)
+ 2
you can do more than just print the results
def myfunction():
function_code = "text"
return function_code
function_text = myfunction()
the function will set function_code to "text" and return will return the "text" where the function was called. It was called within a variable so the variable gets the return value.
you can then use this in other code, or check that its there with;
print(function_text)
which will print the value of function_code since you returned it.
you can return multiple variables in the same line, and any type of data; string, bool, int, float, ect