+ 1

Password validation

Test case 13 is showing error

17th Apr 2020, 7:20 AM
Mannam Rama krishna
Mannam Rama krishna - avatar
7 Answers
1st May 2020, 5:52 AM
Yaswanth
Yaswanth - avatar
+ 1
#include <stdio.h> main() { char s[100]; scanf("%s",&s); int i,length ,numbers=0, special_characters=0; length=strlen(s); for(i=0;i<length;i++){ if(s[i]>='0'&&s[i]<='9'){ numbers++; } else if(s[i]=='!'||s[i]=='@'||s[i]=='#'||s[i]=='
#x27;||s[i]=='%'||s[i]=='&'||s[i]=='*'){ special_characters++; } } if(length>=7 && special_characters>=2 && numbers>=2){ printf("Strong"); } else { printf("Weak"); } } You can try this one.. .
2nd May 2020, 6:16 AM
View My Project
View My Project - avatar
0
Show your code
17th Apr 2020, 8:35 AM
Wasi
Wasi - avatar
0
import re password=input() flag=0 while True: if(len(password)<7): flag=-1 break; elif not(re.search("[0-9]",password)): flag=-1 break; elif not(re.search("[a-z]",password)): flag=-1 break; elif not(re.search("[A-Z]",password)): flag=-1 break; elif not(re.search("[$!%*#&@]",password)): flag=-1 break; else: flag=0 print('Strong') break; if(flag==-1): print('Weak')
17th Apr 2020, 8:54 AM
Mannam Rama krishna
Mannam Rama krishna - avatar
0
I have problems with the same code. I think you just ask for one number and one symbol instead of two. In addition there is no need for a-z and A-Z to be in the password, is there? So it could be effected just letters a-z and no A-Z and still fit the criteria, as I understand the description.
17th Apr 2020, 10:58 AM
Thorsten Mielke
Thorsten Mielke - avatar
0
I just checked your code: One symbol and one number will solve the problem if you just leave out the elif with a-z and A-Z
17th Apr 2020, 7:19 PM
Thorsten Mielke
Thorsten Mielke - 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:14 PM
Mas'ud Saleh
Mas'ud Saleh - avatar