+ 3

Password validation

Didn't pass, test 13 and 14, anyone can help me? https://code.sololearn.com/cFhDsw8xC650/?ref=app

20th Feb 2020, 5:58 AM
Arthur Barbosa
Arthur Barbosa - avatar
9 Respuestas
+ 3
no need to use set() on the findall result of symbol, it will reduce the actual number of symbol. for example, aabb22!! will be counted weak while it is actually strong. another chance of improvement is that, instead of using nested if, use and to combine the three condition into one if.
20th Feb 2020, 6:24 AM
Gordon
Gordon - avatar
1st May 2020, 5:51 AM
Yaswanth
Yaswanth - avatar
+ 2
It seems SL has added more test cases, my old solution did not work on this one either and failed the same tests. I was also using sets in my solution. The task demands to have at least 2 special characters in the password, but in fact they can be the same special character. So something like hell$w$rld99 should be valid. Review how you use sets because they eliminate duplicates.
20th Feb 2020, 6:24 AM
Tibor Santa
Tibor Santa - avatar
+ 2
The problem was the set()! Thanks everybody for the answers! Tibor Santa Gordon WhyFry
20th Feb 2020, 11:15 AM
Arthur Barbosa
Arthur Barbosa - avatar
+ 2
s=input() l=list(s) c=0 for i in l: if type(i)==int: c+=1 d=0 for i in l: if 34<ord(i)<39 or ord(i)==33 or ord(i)==42 or ord(i)==64: d+=1 if d>=2 and c>=2 and len(s)>=7: print ('Strong') if d<2 or c<2 or len(s)<7: print ('Weak')
5th Oct 2020, 6:10 AM
U0FLRVRI
U0FLRVRI - avatar
22nd Jun 2022, 5:21 PM
Joe Davies
Joe Davies - 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:08 PM
Mas'ud Saleh
Mas'ud Saleh - avatar
0
x = input() l = ['!', '@', '#', '
#x27;, '%', '&', '*'] countd = 0 countl = 0 for i in x: if i.isdigit(): countd += 1 elif i in l: countl += 1 if countd >= 2 and countl >= 2 and len(x) >= 7: print('Strong') else: print('Weak')
28th Jan 2022, 5:05 AM
eli_learns_python
eli_learns_python - avatar