题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
a = input() score = 0 # length if len(a) <= 4: score += 5 elif len(a) <= 7: score += 10 else: score += 25 jarge = [0,0,0,0] # xiaoxie, daxie, shuzi, fuhao for i in a: if ord('a') <= ord(i) <= ord('z'): jarge[0] += 1 elif ord('A') <= ord(i) <= ord('Z'): jarge[1] += 1 elif ord('0') <= ord(i) <= ord('9'): jarge[2] += 1 else: jarge[3] += 1 # 字母 if jarge[0] == 0 and jarge[1] == 0: # 没有字母 score += 0 elif (jarge[0] == 0 and jarge[1] >0) or (jarge[1] == 0 and jarge[0] >0): #全都是小(大)写字母 score += 10 elif jarge[0] > 0 and jarge[1] > 0: # 大小写混合 score += 20 # 数字 if jarge[2] == 0: # 没有数字 score += 0 elif jarge[2] == 1: # 1个数字 score += 10 elif jarge[2] > 1: score += 20 # 符号 if jarge[3] == 0: # 没有符号 score += 0 elif jarge[3] == 1: # 1个符号 score += 10 elif jarge[3] > 1: score += 25 if jarge[0]>0 and jarge[1]>0 and jarge[2]>0 and jarge[3]>0: score += 5 elif (jarge[0]>0 or jarge[1]>0) and jarge[2]>0 and jarge[3]>0: score += 3 elif (jarge[0]>0 or jarge[1]>0) and jarge[2]>0: score += 2 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') elif score >= 0: print('VERY_WEAK')