+ 6

What's wrong with this password validation task4 problem?

user = input() store = ['!', '@', '#', '

#x27;, '%', '&', '*'] sp = '' di = '' st = '' tot = 0 for i in user: if i in store: sp += i elif i.isdigit(): di += i elif i.isalnum(): st += i else: tot += 1 if len(sp) >= 2 and len(di) >= 2: print('Strong') else: print('Weak')

13th May 2022, 12:08 PM
yonas
yonas - avatar
4 Antworten
+ 6
The password must be at least 7 characters long. That is what you do not implemented yet.
13th May 2022, 12:25 PM
JaScript
JaScript - avatar
+ 5
Find out why your code is failing for input case : 12@@ edit: take length constraint into count
13th May 2022, 12:14 PM
Jayakrishna 🇮🇳
+ 5
if len(sp) >= 2 and len(di) >= 2 and len(user) > 7:
13th May 2022, 12:33 PM
yonas
yonas - avatar
+ 5
yonas , shouldn't it be like that: ... if len(sp) >= 2 and len(di) >= 2 and len(user) >= 7: ... you also check with isalnum(), but this is never used. btw, this checks for alphabetical characters and also for digits. to check for only alphabetical characters we can use isalpha()
13th May 2022, 2:17 PM
Lothar
Lothar - avatar