+ 1
Password validation
Test case 13 is showing error
7 Answers
+ 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..
.
0
Show your code
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')
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.
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
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")