Password validation password validation test cases | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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=["%", "#","*","!","

quot;,"&","@"] 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")

17th Oct 2021, 7:51 AM
Fernando Zamora
Fernando Zamora - avatar
5 Answers
+ 4
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=["%", "#","*","!","
quot;,"&","@"] 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")
17th Oct 2021, 8:48 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 3
Fernando Zamora , in one of the else clauses you wrote "weak" instead of "Weak".
17th Oct 2021, 8:28 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
Thanks! I fixed that, but it wasnt the issue. Case 7 still fail.
17th Oct 2021, 8:30 AM
Fernando Zamora
Fernando Zamora - avatar
0
That f to g change was the fix! Thank you!
17th Oct 2021, 8:23 PM
Fernando Zamora
Fernando Zamora - avatar
0
password = list(input()) str = " ".join(password) #a string with space b/w the items import re symb = re.findall("[!@#\$%&\*]+", str) num = re.findall(r"[0-9]+", str) filt = filter((lambda x: x in symb,str), (password)) print ("Strong" if len(symb) >= 2 and len(num) >= 2 and len(password) >=7 else "Weak")
5th Dec 2021, 8:14 PM
Mas'ud Saleh
Mas'ud Saleh - avatar