+ 2

Password validation

Test 10 and 11 don’t pass My code pw = set(input()) nums = {'1','2','3','4','5','6','7','8','9','0'} sp = {'!', '@', '#', '

#x27;, '%', '&', '*'} numcheck = pw & nums spcheck = pw & sp if len(numcheck) >= 2 and len(spcheck) >= 2 and len(pw) >= 7: print('Strong') else: print('Weak')

9th Nov 2021, 11:47 AM
°-°
°-° - avatar
4 Answers
+ 4
Hmm, what is about this PW: AAB**55 7 chars, 2 numbers, 2 special Should be strong. But how to count numbers and specials and length after converting it to a set? đŸ€”
9th Nov 2021, 12:41 PM
Coding Cat
Coding Cat - avatar
+ 3
Thanks, I’ll try to fix that
9th Nov 2021, 12:57 PM
°-°
°-° - avatar
+ 2
Task: Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has at a minimum 2 numbers, 2 of the following special characters ('!', '@', '#', '
#x27;, '%', '&', '*'), and a length of at least 7 characters. If the password passes the check, output 'Strong', else output 'Weak'.
9th Nov 2021, 12:10 PM
°-°
°-° - 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:15 PM
Mas'ud Saleh
Mas'ud Saleh - avatar