You will write a function that determines if a password is "strong" or "weak". Your function willhave one parameter, the password given as a string, and return the string "strong" or "weak"depending on the password. A password is strong only if it meets ALL of these criteria:1.It is 8 or more characters long2.It contains a digit (0-9)3.It contains an uppercase letter (A-Z)4.It contains a lowercase letter (a-z)5.It contains one of these five special characters "@*&$!"

Respuesta :

Answer:

def checkStrength(password):

   lower = False

   upper = False

   digit = False

   length = False

   characters = False

   chars = ["@", "*", "&", "$", "!"]

   if len(password) < 8:

       length = False

   else:

       length = True

   for c in password:

       if c.isdigit():

           digit = True

       if c.islower():

           lower = True

       if c.isupper():

           upper = True

       if c in chars:

           characters = True

   if lower and upper and digit and length and characters:

       return "Strong"

   else:

       return "Weak"

print(checkStrength("Ab@134122102"))

end