Answer to Question #303096 in Python for rgtd

Question #303096

Define a function named "isValidPassword" which take a string as parameter. The function will


then check if the supplied string fulfilled the following password criterias:


1) must have combination of uppercase and lowercase


2) must have at least 3 digits


3) must have at least 2 special character (including whitespace).


4) must have at least 10 characters (combination of alphanumeric and special symbol)


The function will return a Boolean value i.e. True if all criterias are met or return False


otherwise.


Make sure you test your function with every single possible input that may return False value


as well.


1
Expert's answer
2022-02-28T01:04:39-0500
def isValidPassword(pass):
  special = ['@', '#', '$', '%', '^', '&', '*', ' ']
  if not any(c.islower() for c in psw):
    return False
  if not any(c.isupper() for c in psw):
    return False
  if 3 > sum(c.isdigit() for c in psw):
    return False
  if 2 > sum(c in special for c in pws):
    return False
  return len(psw) >= 10

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS