+ 1
This is Password validation code but why it's not working?
def main(): password = input() if validator(password): print("Strong") else: print("Weak") def validator(str): if len(str) < 7: return False digits = 0 for x in str: if x.isdigit(): digits += 1 if digits<2: return False special=0 for s in str: if x in ['!', '@', '#', '
#x27;, '%', '&', '*']: special += 1 if special<2: return False else: return True main()7 Antworten
+ 5
after you return something from a function, it stops the execution
+ 5
Pls ellaborate. What do you mean by "not working"? Pls explain what it should do and what it's doing instead. Knowing what's wrong is the very first step to fix it.
Also, instead of pasting the code, link it from Code Playground. Just edit your question description, tap "+" button, then "Code", and select yours. This allows us to test your code, without risk of copy errors.
+ 3
I throw in a guess too.
With the special characters you named the variable s but test x in the list.
for s in str:
if x in [...]
special += 1
+ 1
Thanks for help, problem was that I named variable s but test x in the list😅
+ 1
Now code passed every test
+ 1
You're welcome :)
0
Symbols requirements....two symbols or two "different" symbols.