简体   繁体   中英

Why isn't my password checker working?

It seemed to work fine until I started the 'is this in this string' bit.

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

The error message that comes up: continue not properly in loop. What is wrong? It worded fine until the 'continue' parts and I don't know what's wrong... I would appreciate any help please...

I think the problem is in these lines of code

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

and so on your UPPERCASE variable is a list of characters and EnteredPassword is a string in that case "in" won't be able to fulfill what you are trying to do here.

and secondly "continue" is not working here as you have expected !

Just saw somebody already commented that out. apology for repetition !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM