Python Learning: Automate Boring Stuff with Python | Solution to Part II Chapter 7 Practice Project I


import re
#eight chars long #upper and lower case chars #at least one digit

patternHasDigit = re.compile(r"\d+")
patternHasLower = re.compile(r"[a-z]+")
patternHasUpper = re.compile(r"[A-Z]+")

patterns = (patternHasDigit, patternHasLower, patternHasUpper)
tests = ["asdfgh57887", "Asfkg35a", "23454990-","ASHGFDSFGHFDSDFGDS"]
for test in tests:
    status = True 
    for pattern in patterns:
        if == None:
            print("{} failed {} test".format(test, pattern.pattern))
            status = False 
        if status: 
            print("{} did match".format(test))
            print("{} did not match".format(test)) 
        status = True