+ 2
Password validation
import re str = input() flag =0 while True: if (len(str)<6): flag =-1 break elif not re.search("[_@$]",str): flag =-1 break elif not re.search("[0-9]",str): flag =-1 break else: flag =0 print("Strong") break if flag == -1: print ('Weak') Pls tell what is wrong 😅
4 ответов
+ 4
For input = He!!00World
Your code outputs = "Weak"
Expected output = "Strong"
+ 3
2 out of 13 failed
+ 1
import re
str = input()
flag =0
while True:
if (len(str)<6):
flag =-1
break
elif not re.search("[_!#@%&*$]",str):
flag =-1
break
elif not re.search("[0-9]",str):
flag =-1
break
else:
flag =0
print("Strong")
break
if flag == -1:
print ('Weak')
You just missed some of the special characters...which I have included..now your code works fine.. I hope it helps🙃
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")