Python 循环题目:要求创建一个密码检查的代码,先检查长度,正确后再检查强度

Python 循环题目:要求创建一个密码检查的代码,首先要计算输入代码的长度,必须满足6-8,否则提示需要重新输入知道满足长度;密码满足长度后,在检查的密码的强度,如果只包含数字则显示弱,只包含字母显示弱,其他则显示强,并输出密码长度
题目如上,遇到的问题:密码在第一个while循环后不能进入第二个循环,也就是长度符合后不能检测强弱

MIN_PASSWORD_LENGTH = 6
MAX_PASSWORD_LENGTH = 8

password = input("Enter your password:")
password_length = len(password)

while not 6 <= password_length <= 8:
print("Invalid-password_length must between 6 and 8")
input("Enter your password:")
while 6 <= password_length <= 8:
if password.isalpha():
print("password weak - only contains letters")
elif password.isdigit():
print("password weak - only contains numbers")
else:
print("password strong")

print("the length of the password is:{}".format(password_length))


MIN_PASSWORD_LENGTH = 6
MAX_PASSWORD_LENGTH = 8

password = input("Enter your password:")
password_length = len(password)
while 1:
    if not 6 <= password_length <= 8:
        print("Invalid-password_length must between 6 and 8")
        password = input("Enter your password:")
        password_length = len(password)
    elif 6 <= password_length <= 8:
        break
while 6 <= password_length <= 8:
    if password.isalpha():
        print("password weak - only contains letters")
        break
    elif password.isdigit():
        print("password weak - only contains numbers")
        break
    else:
        print("password strong")
        break

print("the length of the password is:{}".format(password_length))

如有用请采纳