Python定义问题。

定义一个名为“isValidPassword”的函数,它接受一个字符串作为参数。然后,该函数将检查提供的字符串是否满足以下密码标准:
1)必须是大写和小写的组合2)必须至少有3位数字
3)必须至少有2个特殊字符(包括空格)
4)必须至少有10个字符(字母数字和特殊符号的组合)
该函数将返回一个布尔值。如果满足所有条件则为True,否则返回False。
确保你用每个可能返回False值的输入来测试你的函数

你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)

def isValidPassword(s):
    upper=0
    lower=0
    digit=0
    other=0
    for c in s:
        if c.isupper():
            upper+=1
        elif c.islower():
            lower+=1
        elif c.isdigit():
            digit+=1
        else:
            other+=1
    return len(s)>=10 and upper>=1 and lower>=1 and digit>=3 and other>=2

print(isValidPassword('AAAbbb123 !')) #true
print(isValidPassword('AAbb123 !')) #false
print(isValidPassword('aaabbb123 !')) #false
print(isValidPassword('AAABBB123 !')) #false
print(isValidPassword('AAAbbb12 !')) #false
print(isValidPassword('AAAbbb123!')) #false