Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Password Validator using regex
- import re
- while True:
- print("Enter Password")
- password = input(" ").strip()
- pattern1 = r"[12345678097]"
- pattern2 = r"[*#@!^#$%]"
- pattern3 = r"[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]"
- if len(password) >=8:
- if re.search(pattern3, password):
- if re.search(pattern1, password):
- if re.search(pattern2, password):
- break
- else:
- print("Password must contain special characters or symbols")
- continue
- else:
- print("Password must contain numbers")
- continue
- else:
- print("Password must contain letters")
- continue
- else:
- print("Password too short")
- continue
- print("Valid Password")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement