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

时间:2016-05-20 09:59:20

标签: python while-loop indentation

它似乎工作正常,直到我开始了这个字符串'位。

#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")   

出现的错误消息:     继续没有正确循环。 怎么了?它的措辞很好,直到“继续”#39;部分,我不知道什么是错的...... 我很感激任何帮助...

1 个答案:

答案 0 :(得分:0)

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

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

等等 您的UPPERCASE变量是一个字符列表,EnteredPassword是一个字符串 在那种情况下&#34;在&#34;无法满足你在这里想要做的事情。

其次&#34;继续&#34;没有像你预期的那样在这里工作!

刚看到有人已经评论过了。 道歉重复!