Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question Four Write a Python program that accepts a list of passwords (separated by commas) from the user. For each password in the list, the
Question Four Write a Python program that accepts a list of passwords (separated by commas) from the user. For each password in the list, the program should call a function to verify whether or not the password is valid. Valid passwords should meet the following rules: . a. At least 8 characters and no more than 15 characters . b. Must begin with two lower case alphabets . C. At least one occurance of two consecutive uppercase letters . d. At least one occurance of a two digit number . e. Exactly one of the following special characters (#, %, @, &) Sample Interaction Enter the passwords separated by commas: chipmunk@2015, CHIPmunk@2015, chipmunk@2015, chipmunk@#20aa, chipmunk@2, chIPm, chipmunk@2015chip chipmunk@2015 matches password rules CHIPmunk@2015 does not match password rules Password must start with two lowercase letters! chipmunk@2015 does not match password rules Password must contain at least one occurance of two consecutive uppercase letters! chIPmunk@#20aa does not match password rules Password must contain exactly one occurance of one of the special characters #%@\\$ chipmunk@2 does not match password rules Password must contain at least one occurance of two consecutive digits! chIPm does not match password rulespassword=input ( "Enter the passwords separated by commas: ") pwd=list (password. split(",") ) def valid_pass (pwd) : special_char=0 num=0 upper=0 for item in pwd: if len (item)>=6: for char in item: if (char=='#' or char=s's' or char=s'@' or char=='& ') : special_char+=1 if ( char . isdigit( ) ) : num+=1 if ( char . isupper ( ) ) : upper+=1 if (special_char>=1 and num>=1 and upper>=1) : print (item, "matches password rules") else: print (item, "does not match password rules. Password must start with two lowercase letters." ) else: print(item, "does not match password rules. Password must contain at least one occurance of two cor else: print(item, "does not match password rules. Password must contain exactly one occurance of one of else: print(item, "does not match password rules. Password must contain at least one occurance of two con else: print (item, "does not match password rules. Password must be between 8 and 15 characters long.") valid_pass (pwd) File "", line 22 else: SyntaxError: invalid syntax
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started