automate-boring-stuff/exercises/ex07/ex07c.py

33 lines
636 B
Python

"""
Project: Strong Password Detection
Page 186
"""
import re
tests = [
"",
"a",
"aaaaaaaa",
"AAAAAAAA",
"11111111",
"aAaAaAaA",
"a1a1a1a1",
"A1A1A1A1",
"aA1aA1aA1",
]
def check_pass(string):
withupper = True if re.match(r".*[A-Z]", string) else False
withlower = True if re.match(r".*[a-z]", string) else False
withdigit = True if re.match(r".*\d", string) else False
if len(string) >= 8 and withupper and withlower and withdigit:
print(f"'{string}' is a strong pass")
else:
print(f"'{string}' is NOT a strong pass")
for test in tests:
check_pass(test)