+ 1

Password validating

I m mindless on which scenario I missed, 2/17 failed. 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'. Input Format: A string representing the password to evaluate. Output Format: A string that says 'Strong' if the input meets the requirements, or 'Weak', if not. Sample Input: Hello@$World19 Sample Output: Strong

8th Aug 2020, 7:25 AM
Kiran Vaichalkar
Kiran Vaichalkar - avatar
4 Respostas
+ 2
Kiran Vaichalkar that's the link to the question ,not the answer. For answer ,copy paste the code in code playground and then share it here.
8th Aug 2020, 7:41 AM
Arsenic
Arsenic - avatar
+ 2
There are a number of bugs that I was able to find in this code :- 1) you are not checking wether length is greater than 7 or not 2) " * " special characters is missing in your list 3) the answer should have 2 numbers AND 2 special characters (not 2 in total)
8th Aug 2020, 7:56 AM
Arsenic
Arsenic - avatar
+ 1
a=input().split() a.extend([['!','@','#','
#x27;,'%','&'],list(range(10))]) n=0 for i in a[0]: if i in a[1] or i in a[2]: n+=1 print('Strong' if len(a[0])-(len(a[0])-n)>=2 else 'Weak')
8th Aug 2020, 7:46 AM
Kiran Vaichalkar
Kiran Vaichalkar - avatar
8th Aug 2020, 7:32 AM
Kiran Vaichalkar
Kiran Vaichalkar - avatar