Provide Python code that does the following:
4) Write a program that asks the user to enter a 9 character password. Test to see if it is a valid password. The validity test is
a) they enter exactly 9 characters AND
b) that every 3rd character, starting with the 1st character is the letter z.
If it is valid print out the message “valid password” otherwise print the message “invalid password”.
Sample output.
Please enter a password: zaazbbz12
valid password
Please enter a password: Aaazbbz12
invalid password
Please enter a password: zaaz
invalid password
password = input('Please enter a password: ') # read password # check if length of password is exactly 9 if len(password) != 9: print('invalid password') else: # check if every 3rd character is z in the password is_valid = True for i in range(0, 9, 3): if password[i] != 'z': is_valid = False break if is_valid: print('valid password') else: print('invalid password')
FOR HELP PLEASE COMMENT.
THANK YOU
Get Answers For Free
Most questions answered within 1 hours.