为什么我的密码检查器不工作?

2024-03-28 10:15:04 发布

您现在位置:Python中文网/ 问答频道 /正文

它似乎很好地工作,直到我开始'这是在这个字符串'位。你知道吗

#This is the introduction to the code
import time
MinPass = 6
MaxPass = 12
Uppercase = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
Lowercase = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
Symbols = ["!", "£", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "=", ":", ";", "@", "'", "#", "~", "<", ">", "?", "/", "|", "¬", "`"]
print ("Hello, user, welcome to the SSPC program, or the Safe and Secure Password Creater.")

print ("Please type your name")
NAME = input()
print ("Great. For a secure password, do not use your name,", NAME, "!")
time.sleep(2)
print ("Now, lets try with a password. Please enter one here")
EnteredPassword = input("Password: ")
while len(EnteredPassword) < MinPass:
    print ("That password is too small. Please try again")
    EnteredPassword = input("Password: ")
while len(EnteredPassword) > MaxPass:
    print ("That password is too long, please try again")
    EnteredPassword = input("Password: ")
print ("Ok, that password is great!")

if EnteredPassword not in Uppercase:
    continue
    if EnteredPassword not in Symbols:
        print ("Your password is weak")
        continue
elif EnteredPassword in Uppercase:
    continue
    if EnteredPassword in Lowercase:
        continue
    elif EnteredPassword not in Lowercase:
        continue
        if EnteredPassword in Symbols:
            print ("Your password is medium")
        elif EnteredPassword not in Symbols:
            print ("Your password is weak")
elif EnteredPassword in Lowercase:
    continue
    if EnteredPassword in Uppercase:
        continue
        if EnteredPassword in Symbols:
            print ("Your password is strong")
elif EnteredPassword not in Lowercase:
    continue
    if EnteredPassword in Symbols:
        print ("Your password is medium")
    elif EnteredPassword not in Symbols:
        print ("Your password is weak")   

出现的错误消息: 在循环中不正确地继续。 怎么了?它的措辞很好,直到'继续'的部分,我不知道是什么错。。。 我会感激任何帮助请。。。你知道吗


Tags: theinyourifisnotpasswordprint
1条回答
网友
1楼 · 发布于 2024-03-28 10:15:04

我认为问题出在这些代码行上

if EnteredPassword not in Uppercase:
    ...
elif EnteredPassword in Uppercase:
    ...

等等 大写变量是字符列表,EnteredPassword是字符串 在这种情况下,“in”将无法完成你在这里试图做的事情。你知道吗

第二,“继续”并不像你所期望的那样在这里工作!你知道吗

只是看到有人已经评论过了。 为重复道歉!你知道吗

相关问题 更多 >