我被要求创建一个程序来识别密码是否有效。我正在努力解决的一个部分是确定是否有两个相同的字符彼此相邻。帮助将不胜感激,这是迄今为止的程序:
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.")
Run Code Online (Sandbox Code Playgroud)