+ 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()

7th Mar 2023, 10:22 PM
giorgi
giorgi - avatar
7 odpowiedzi
+ 5
after you return something from a function, it stops the execution
7th Mar 2023, 11:24 PM
Lamron
Lamron - avatar
+ 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.
8th Mar 2023, 1:45 AM
Emerson Prado
Emerson Prado - avatar
+ 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
8th Mar 2023, 5:02 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Thanks for help, problem was that I named variable s but test x in the list😅
8th Mar 2023, 8:37 AM
giorgi
giorgi - avatar
+ 1
Now code passed every test
8th Mar 2023, 8:37 AM
giorgi
giorgi - avatar
+ 1
You're welcome :)
8th Mar 2023, 8:38 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
Symbols requirements....two symbols or two "different" symbols.
8th Mar 2023, 8:02 AM
rodwynnejones
rodwynnejones - avatar