0
I didnt know how to run my defined function.
6 Respostas
+ 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.
+ 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.
+ 5
Tibor Santa
ohhhh thanks👍
+ 3
Thanks for both of you Tibor Santa and Oma Falk. 😁 i can’t tick both sadly
+ 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 ☺️
+ 2
Tibor Santa Thanks a lot!!😁