Password validation | Sololearn: Learn to code for FREE!

+2

Password validation

import re str = input() flag =0 while True: if (len(str)<6): flag =-1 break elif not re.search("[[email protected]$]",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 ๐Ÿ˜…

10/14/2020 4:04:26 PM

Pritee

4 Answers

New Answer

+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("[[email protected]#\$%&\*]+", 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")