我正在建立一个程序,将检查用户的密码是否低于6个字符或超过10个字符,并继续检查它是否强大。如果不超过6个字符或少于6个字符,它将继续要求用户输入少于10个字符和多于6个字符的密码。尝试使用while循环,但无效。提前谢谢
if password.isalpha(): # If python detects the input is all letters, it will-
message = "password weak – contains only letters" # Choose this message and present it on prompt from line 35
elif password.isnumeric(): # If python detects the input is not all alphabetical letters, it proceeds to this method-
message = "password weak – contains only numbers" # and chooses this message and presents it on prompt from line 35
else:
message = "password strong" # If the password input is a mixture of letters & numbers, it will print this message-
print(message) # and will be prompted to show for this line of code.
或者简单地在循环中
两者都给我的输出如下
试试这个逻辑。 Flag=1表示密码为强密码
相关问题 更多 >
编程相关推荐