题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
# 分块
s = input() score = 0 # 一、长度 if len(s) >= 8: score += 25 elif len(s) >= 5: score += 10 else: score += 5 c = 0 # 数字计数 o = 0 # 字符计数 alp = [0, 0] # 有无大小写字母 for i in s: if i.isupper(): alp[0] = 1 elif i.islower(): alp[1] = 1 elif i.isdigit(): c += 1 else: o += 1 # 二、字母 if sum(alp) == 2: score += 20 elif sum(alp) == 1: score += 10 # 三、数字 if c > 1: score += 20 elif c == 1: score += 10 # 四、符号 if o > 1: score += 25 elif o == 1: score += 10 # 五、奖励 if sum(alp) == 2 and c and o: score += 5 elif sum(alp) == 1 and c and o: score += 3 elif sum(alp) == 1 and c: score += 2 # print 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')