Password Strength Detector I'm just a beginner in Python. I wrote a simple code that detects the user's password strength, but I feel that it isn't very efficient. How can I improve it? 

print('''# This is Password Strength Detector.\n
-----------------------------------------------------------------''')
password = input('Enter your password here : ')
print('\n')

from re import *

lower_match = compile(r'[a-z]').findall(password)  # Finding if the password contains lowecase letters.
upper_match = compile(r'[A-Z]').findall(password)  # Finding if the password contains uppercase letters.
symbol_match = compile(r'[|\"|\'|~|!|@|#|$|%|^|&amp;|*|(|)|_|=|+|\||,|.|/|?|:|;|[|]|{\}|&lt;|&gt;]').findall(
    password)  # Finding if the password contains special characters.
number_match = compile(r'[0-9]').findall(password)  # Finding if the password contains numbers.

if len(password) &lt; 8 or len(lower_match) == 0 or len(upper_match) == 0 or len(symbol_match) == 0 or len(
        number_match) == 0:
    print('Your password is weak ! ')

elif len(password) &gt;= 8:
    print('Your password is strong ! ')

elif len(password) &gt;= 16:
    print('Your password is very strong ! ')
The strength of a password has nothing to do with the presence of special characters! Obligatory xkcd reference:



correct horse battery staple is a very strong password, but you would classify it as weak, simply because it doesn't contain capital letters, symbols, or numbers. Rethink the idea.

Testing

You will never indicate that a password is very strong because of this ordering:

elif len(password) &gt;= 8:
    print('Your password is strong ! ')
elif len(password) &gt;= 16:
    print('Your password is very strong ! ')


If len(password) is, say, 20, both branches are true. So you want to makes ure that the most restrictive one goes first:

elif len(password) &gt;= 16:
    print('Your password is very strong ! ')
else:
    print('Your password is strong ! ')


Regex

The point of compile is if you reuse the same regex many times, you can make it more efficient. You use each one exactly once, so it's a waste of processing time. What you want to instead use is re.search(), since you don't care about all the instances you just want to know if there is such a thing:

lower_match = re.search(r'[a-z]', password)
upper_match = re.search(r'[A-Z]', password)
...


Then check against None instead of checking len(). Also your symbol check is inefficient. You have a bunch of |s, when you could simply list them all:

symbol_match = re.search(r'[\"\'~!@#$%^&amp;\\*\(\)_=\+\|,./\?:;\[\]\{\}&lt;&gt;]', password)


Importing

from X import *


is highly frowned upon. Just do import re and use re.X everywhere.