def check_password_strength(password):
 password = unicode(password)
 n = math.log(len(set(password)))
 num = ((re.search('[0-9]', password) is not None) and (re.match('^[0-9]*$', password) is None))
 caps = ((password != password.upper()) and (password != password.lower()))
 extra = (re.match('^[a-zA-Z0-9]*$', password) is None)
 score = ((len(password) * (((n + caps) + num) + extra)) / 20)
 password_strength = {0: 'Weak', 1: 'Medium', 2: 'Strong', 3: 'Very Strong'}
 return password_strength[min(3, int(score))]

def check_password_strength ( password ) : password = unicode ( password ) n = math . log ( len ( set ( password ) ) ) num = ( ( re . search ( '[0-9]' , password ) is not None ) and ( re . match ( '^[0-9]*$' , password ) is None ) ) caps = ( ( password != password . upper ( ) ) and ( password != password . lower ( ) ) ) extra = ( re . match ( '^[a-zA-Z0-9]*$' , password ) is None ) score = ( ( len ( password ) * ( ( ( n + caps ) + num ) + extra ) ) / 20 ) password_strength = { 0 : 'Weak' , 1 : 'Medium' , 2 : 'Strong' , 3 : 'Very Strong' } return password_strength [ min ( 3 , int ( score ) ) ]
check the strength of the password entered by the user and return back the same .