I didnt know how to run my defined function. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I didnt know how to run my defined function.

https://code.sololearn.com/c9dvONPMNloG/?ref=app

17th May 2020, 7:17 AM
Amin Wali
Amin Wali - avatar
6 Answers
+ 4
You can run your function by writing its name and parentheses, for example in line 19 add: sec1() sec2() But there are other fundamental issues with your program.. You store the result in a global variable (securitypass) but you do not increment its value. And the functions don't have access to modify that variable, because it is outside of their scope.
17th May 2020, 7:24 AM
Tibor Santa
Tibor Santa - avatar
+ 6
https://code.sololearn.com/c0bijvaA89gW/?ref=app key is only used in your function. so better define it there. This and a few other ideas i tried to show you.
17th May 2020, 7:24 AM
Oma Falk
Oma Falk - avatar
+ 5
Tibor Santa ohhhh thanks👍
17th May 2020, 12:08 PM
Oma Falk
Oma Falk - avatar
+ 3
Thanks for both of you Tibor Santa and Oma Falk. 😁 i can’t tick both sadly
17th May 2020, 7:25 AM
Amin Wali
Amin Wali - avatar
+ 3
Oma Falk you were sloppy this time 🤣 You left two bugs in your nice sample program. Line 15 should be: if any(k in pw for k in key): Line 21 should be: if sec1(Password ) and sec2(Password): Biggymin I recommend to study this approach with functions and try to embrace it. A function has the purpose to answer a question. It works with some data, that is the parameters. It does some calculation or logic that does not depend on any external factors or variables, only on the input. And it provides a result, that is the return value. Use this pattern and you will avoid a lot of potential issues and bugs, that can be caused by shared global variables ☺️
17th May 2020, 7:53 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Tibor Santa Thanks a lot!!😁
17th May 2020, 7:54 AM
Amin Wali
Amin Wali - avatar