题解 | #密码强度等级#

密码强度等级

https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361

import sys

for line in sys.stdin:
    a = line.strip()
    fenshu = 0
    if len(a) <= 4:fenshu +=5
    elif 4 < len(a) <= 7:fenshu += 10
    else:fenshu +=25
    daxie,xiaoxie,numcount,fuhaocount = False,False,0,0
    for i in a:
        if i.islower():xiaoxie = True
        elif i.isupper():daxie = True
        elif i.isdecimal():numcount+=1
        else:fuhaocount+=1
    if daxie and xiaoxie:fenshu += 20
    elif daxie or xiaoxie:fenshu+=10

    if numcount >1:fenshu+=20
    elif numcount == 1:fenshu+=10

    if fuhaocount>1:fenshu+=25
    elif fuhaocount == 1:fenshu+=10

    if daxie and xiaoxie and numcount>0 and fuhaocount>0:
        fenshu+=5
    elif numcount>=1 and (daxie or xiaoxie) and fuhaocount>0:
        fenshu+=3
    elif  numcount>=1 and (daxie or xiaoxie):
        fenshu +=2
    if fenshu >=90:
        print('VERY_SECURE')
    elif fenshu >= 80:
        print('SECURE')
    elif fenshu >= 70:
        print('VERY_STRONG')
    elif fenshu >= 60:
        print('STRONG')
    elif fenshu >= 50:
        print('AVERAGE')
    elif fenshu >= 25:
        print('WEAK')
    else:print('VERY_WEAK')


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务