为什么我的密码检查器不工作?
Why isn't my password checker working?
在我启动 'is this in this string' 位之前它似乎工作正常。
#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")
出现的错误信息:
在循环中继续不正确。
怎么了?在 'continue' 部分之前它的措辞很好,我不知道出了什么问题......
如果有任何帮助,我将不胜感激...
我认为问题出在这些代码行中
if EnteredPassword not in Uppercase:
...
elif EnteredPassword in Uppercase:
...
等等
您的 UPPERCASE 变量是一个字符列表,而 EnteredPassword 是一个字符串
在那种情况下 "in" 将无法完成您在这里尝试做的事情。
其次,"continue" 没有像您预期的那样在此处工作!
刚看到有人已经评论出来了。
为重复道歉!
在我启动 'is this in this string' 位之前它似乎工作正常。
#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")
出现的错误信息: 在循环中继续不正确。 怎么了?在 'continue' 部分之前它的措辞很好,我不知道出了什么问题...... 如果有任何帮助,我将不胜感激...
我认为问题出在这些代码行中
if EnteredPassword not in Uppercase:
...
elif EnteredPassword in Uppercase:
...
等等 您的 UPPERCASE 变量是一个字符列表,而 EnteredPassword 是一个字符串 在那种情况下 "in" 将无法完成您在这里尝试做的事情。
其次,"continue" 没有像您预期的那样在此处工作!
刚看到有人已经评论出来了。 为重复道歉!