Password validation password validation test cases | Sololearn: Learn to code for FREE!

+1

Password validation password validation test cases

I can’t figure out what test case 7 is. This code passes all but 7. I know it might seem like a lot but it makes sense in my booby code brain. a=input() b=list(a) c=len(b) d=list(filter(lambda x: x.isalpha(),b )) f=len(d) e=list(filter(lambda y: y.isdigit(),b)) g=len(e) s=[] m=["%", "#","*","!","$","&","@"] for i in b: for j in m: if i==j: s.append(i) v=len(s) if c>=7: if f>=2: if v>=2: print("Strong") else: print("Weak") else: print("weak") else: print("Weak")

10/17/2021 7:51:41 AM

Fernando Zamora

4 Answers

New Answer

+3

Fernando Zamora , you should make changes in the loop -> no need of two loops, also in your checks "f" is the number of letters of the alphabet in the password, you should check for digits "g". Look at the code: a=input() b=list(a) c=len(b) d=list(filter(lambda x: x.isalpha(),b )) f=len(d) e=list(filter(lambda y: y.isdigit(),b)) g=len(e) s=[] m=["%", "#","*","!","$","&","@"] for i in b: if i in m: s.append(i) v=len(s) if c>=7: if g>=2: if v>=2: print("Strong") else: print("Weak") else: print("Weak") else: print("Weak")

+2

Fernando Zamora , in one of the else clauses you wrote "weak" instead of "Weak".

0

Thanks! I fixed that, but it wasnt the issue. Case 7 still fail.

0

That f to g change was the fix! Thank you!