+ 3
Password validation
Didn't pass, test 13 and 14, anyone can help me? https://code.sololearn.com/cFhDsw8xC650/?ref=app
9 Respostas
+ 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.
+ 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.
+ 2
+ 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')
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")
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')