+ 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

4th Aug 2020, 2:27 PM
Mr. 12
Mr. 12 - avatar
4 Answers
+ 2
Return fucntion works but not that anything after the return statement won't be executed
4th Aug 2020, 2:41 PM
Du Rah
Du Rah - avatar
+ 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)
4th Aug 2020, 2:41 PM
Steven M
Steven M - avatar
+ 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
4th Aug 2020, 3:51 PM
Cody Wanserski
Cody Wanserski - avatar