擅长:python、mysql、java
<p>第一个问题是将未声明的变量传递给函数。详情请参阅silentphoenix的答案。在</p>
<p>其次,程序只检查是否至少满足一个条件,而不是全部。在</p>
<p>如果密码长度为8个字符,则即使密码不满足其他要求,它也将返回true<em>。在</p>
<p>我不会为您编写代码,但我可以对问题进行伪代码:</p>
<pre><code>def validatePassword(pswd):
if len(pswd) < 8:
return False
# if there isn't a number:
return False
# if there isn't a symbol:
return False
# if there isn't an upper and lowercase:
return False
return True
while True:
print("There was an error with your password")
print (validatePassword("Herseuclds"))
</code></pre>
<p>旁注:注意缩进:)</p>