高仿模拟练习,完整编写程序并运行出结果,答案点击按钮展开
输入一个密码字符串,按规则判断强度:长度≥8 且同时含大小写字母和数字为"强",否则为"弱"。输出强度等级。
# 输入示例:Abc12345
# 请在下面编写完整程序
s = input()
has_upper = any(c.isupper() for c in s)
has_lower = any(c.islower() for c in s)
has_digit = any(c.isdigit() for c in s)
if len(s) >= 8 and has_upper and has_lower and has_digit:
print("强")
else:
print("弱")
any+生成器表达式检查是否含大写/小写/数字;满足长度≥8 且三类字符都有为强。