如何确保输入符合要求
答
if any(x.isupper() for x in password) and \
any(x.islower() for x in password) and \
any(x.isdigit() for x in password):
print ("Congratulations, you have a secure password.")
答
你也可以把在一个while循环,不会停止,直到那些条件相匹配:
while True:
password = input("Please enter a password: ")
if any(x.isupper() for x in password) and \
any(x.islower() for x in password) and \
any(x.isdigit() for x in password): #copy from Rob's awnser
break
else: print('Invalid!')
设法解决它的一个组成部分。其余的将会很容易。如果您遇到困难,请告诉我们您尝试了什么。 –