题解 | #密码强度等级#

密码强度等级

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

'''
实现起来不难,
需要写长代码比较繁琐。
'''

s = input()

score = 0
if len(s) <= 4:
    score += 5
elif len(s) > 4 and len(s) < 8:
    score += 10
elif len(s) >= 8:
    score += 25
else:
    pass

la = 0
ua = 0
nu = 0
o = 0
for i in s:
    if i >= 'a' and i <= 'z':
        la += 1
    elif i >= 'A' and i <= 'Z':
        ua += 1
    elif i >= '0' and i <= '9':
        nu += 1
    else:
        o += 1

if la > 0 and ua > 0:
    score += 20
elif la > 0 or ua > 0:
    score += 10
else:
    pass

if nu == 1:
    score += 10
elif nu > 1:
    score += 20
else:
    pass

if o == 1:
    score += 10
elif o > 1:
    score += 25
else:
    pass

if la > 0 and ua > 0 and o > 0 and nu > 0:
    score += 5
elif (la+ua) > 0 and o > 0 and nu > 0:
    score += 3
elif (la+ua) > 0 and nu > 0:
    score += 2
else:
    pass

if score >= 90:
    print('VERY_SECURE')
elif score >= 80:
    print('SECURE')
elif score >= 70:
    print('VERY_STRONG')
elif score >= 60:
    print('STRONG')
elif score >= 50:
    print('AVERAGE')
elif score >= 25:
    print('WEAK')
else:
    print('VERY_WEAK')

#华为机试#
全部评论

相关推荐

评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客企业服务