Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the function is valid() in password.checker.py that returns True if th

ID: 3818711 • Letter: I

Question

Implement the function is valid() in password.checker.py that returns True if the given password string meets the following specifications, and False otherwise: At least eight characters long. Contains at least one digit (0-9). Contains at least one uppercase letter. Contains at least one lowercase letter. Contains at least one character that is neither a letter nor a number. $ python password.checker.py Abcdelfg False $ python password.checker.py Abcdel g True import stdio import sys # Returns True if pwd is a valid password and False otherwise def is valid(pwd): # Test client [DO NOT EDIT]. Reads a password string as command-line argument # and writes True if it's valid and False otherwise def main(): pwd = sys.argv[1] stdio.writeln(is valid(pwd)) if name == '_main_': _main()

Explanation / Answer

def is_valid(pwd)
x=True
while pwd:
if (len(pwd)<8):
break
elif not re.search("[a-z]",p):
break
elif not re.search("[0-9]",p):
break
elif not re.search("[A-Z]",p):
break
elif not re.search("[$#@]",p):
break
elif re.search("s",p):
break
else:   
x=False
break

return x