题解 | #密码强度等级#
密码强度等级
http://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
各种if elif else,最笨的方法肯定有效
s=list(input())
count=0
if len(s)<5:
count+=5
elif 4<len(s)<8:
count+=10
else:
count+=25
num_alp=0
num_upper=0
num_lower=0
for i in s:
if i.isalpha():
num_alp+=1
if i.isupper():
num_upper+=1
elif i.islower():
num_lower+=1
if num_upper>0 and num_lower>0:
count+=20
elif num_upper==0 and num_lower>0:
count+=10
elif num_upper>0 and num_lower==0:
count+=10
else:
count+=0
num_num=0
for i in s:
if i.isdigit():
num_num +=1
if num_num>1 :
count+=20
elif num_num==1:
count+=10
else:
count+=0
num_str=0
for i in s:
if i.isdigit()==False and i.isalpha()==False:
num_str +=1
if num_str>1 :
count+=25
elif num_str==1:
count+=10
else:
count+=0
if num_alp>0 and num_num>0 and num_str==0:
count+=2
elif num_upper==0 and num_lower>0 and num_num>0 and num_str>0:
count+=3
elif num_upper>0 and num_lower==0 and num_num>0 and num_str>0:
count+=3
elif num_upper>0 and num_lower>0 and num_num>0 and num_str>0:
count+=5
if count>=90:
print('VERY_SECURE')
elif 90>count>=80:
print('SECURE')
elif 80>count>=70:
print('VERY_STRONG')
elif 70>count>=60:
print('STRONG')
elif 60>count>=50:
print('AVERAGE')
elif 50>count>=25:
print('WEAK')
else:
print('VERY_WEAK')