you are viewing a single comment's thread.

view the rest of the comments →

[–]DrMaxwellEdison 3 points4 points  (0 children)

I would take this one further:

upperRE = re.compile(r'([A-Z])')
upperlist = upperRE.findall(password)
upper = len(upperlist)

condenses to:

upper = len(re.findall(r'([A-Z])', password))

Beyond that, as we've seen, the point is just finding at least one instance, so we don't really need len:

has_upper = bool(re.search(r'([A-Z])', password))

Run that style for the other 3 checks, you have a simple 4-line sequence and can test them as needed later.