我被要求創建一個程序來識別密碼是否有效。我正在努力的一部分是確定是否有兩個相同的字符彼此相鄰。幫助將不勝感激,這裏是節目至今:確定是否有兩個相鄰字符相同的字符
import re
pswrd = input("Enter Desired Password:")
if len(pswrd) < 6:
print("Password must have more than 6 characters.")
if len(pswrd) > 15:
print("Password must have no more than 15 characters.")
if re.search("[$#@]",pswrd):
print("Password must have no special characters.")
if not re.search("[0-9]",pswrd):
print("Password must contain a number.")
if not re.search("[a-z]",pswrd):
print("Password must contain a lower case letter.")
if not re.search("[A-Z]",pswrd):
print("Password must contain an upper case letter.")
測試和最小密碼長度不同意的答覆。 (「少於6」不是「超過6」的相反) – trentcl