题解 | #密码强度等级#

密码强度等级

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')

全部评论

相关推荐

昨天 17:22
已编辑
西安交通大学 Java
华为 昇腾 ai软件开发 薪资20k x (14-16),职级13A,5%公积金,c/cpp
BLOOMING7:闭眼滴滴,华子给的又少又累
点赞 评论 收藏
分享
像好涩一样好学:这公司我也拿过 基本明确周六加班 工资还凑活 另外下次镜头往上点儿
点赞 评论 收藏
分享
牛客771574427号:恭喜你,华杰
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务