【发布时间】:2016-09-17 13:01:08
【问题描述】:
在我开始“这个字符串中的这个”位之前,它似乎工作正常。
#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")
出现的错误信息: 继续循环不正确。 怎么了?在“继续”部分之前它的措辞很好,我不知道出了什么问题...... 如果有任何帮助,我将不胜感激......
【问题讨论】:
-
在 Python 中,缩进是语言语法的一部分。问题中的缩进是否 100% 与您的代码一样?
-
您应该尝试包含minimal reproducible example 而不是整个程序。这将帮助您自己隔离问题,如果您不能,则可以节省其他人的时间,因为他们不必阅读整个内容。
-
continue是一个立即导致循环语句(for、while)进入下一个迭代的语句。您在没有循环的if语句中使用continue。您可能还想重新检查您的代码。我很确定,例如EnteredPassword not in Uppercase没有达到你的预期。 -
看看regex。顺便说一句,更简单的方法。
-
import string; list(string.ascii_lowercase)或list(string.ascii_uppercase)#=> 字母作为列表;还有list(string.punctuation)#=> 符号
标签: python while-loop indentation