题解 | #密码强度等级#
密码强度等级
https://www.nowcoder.com/practice/52d382c2a7164767bca2064c1c9d5361
lst_symbol ='''!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~''' s = input() score = 0 # lenth if len(s) <= 4: score += 5 if 5 <= len(s) <= 7: score += 10 elif len(s) >= 8: score += 25 # counter low = 0 up = 0 digit = 0 symbol = 0 extra = 0 # reward of alpha # classify for i in s: if i.isupper(): up += 1 if i.islower(): low += 1 if i.isdigit(): digit += 1 if i in lst_symbol: symbol += 1 # alpha if low == 0 and up != 0 or low != 0 and up == 0: score += 10 extra = 1 if low != 0 and up != 0: score += 20 extra = 2 # digit if digit == 1: score += 10 if digit > 1: score += 20 # symbol if symbol == 1: score += 10 if symbol > 1: score += 25 # reward if extra == 1 and digit and not symbol: score += 2 if extra == 1 and digit and symbol: score += 3 elif extra == 2 and digit and symbol: score += 5 # result if score < 25: r = 'VERY_WEAK' elif score < 50: r = 'WEAK' elif score < 60: r = 'AVERAGE' elif score < 70: r = 'STRONG' elif score < 80: r = 'VERY_STRONG' elif score < 90: r = 'SECURE' else: r = 'VERY_SECURE' print(r)