我花了几个小时解决这个问题,但程序无法运行(语法错误)。 检查类似问题的答案没有帮助。下面的代码有什么问题? 我想检查列表(密码)是否至少包含一位数字,以及其中是否包含一个大写字母和一个小写字母。 请为我提供最简单的方法,我是初学者......
def checkio(password):
array = list(password)
#for letter in array:
if len(array) < 10 or len(array) > 64:
return False
if (any(l.isdigit() for l in array) and (any(l.isupper( for l in array) and (any(l.islower for l in array):
return True
else:
return False
最佳答案
你的括号错了。 试试这个。
def checkio(password):
array = list(password)
#for letter in array:
if len(array) < 10 or len(array) > 64:
return False
if ((any(l.isdigit() for l in array)) and (any(l.isupper() for l in array)) and ((any(l.islower() for l in array)))):
return True
else:
return False
关于python - 检查列表中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26854566/