Write a python program to check the validity of password inp

Write a python program to check the validity of password inputted by users. A pass word is valid if the following holds:

- Has at least 1 letter between [a-z[ and 1 letter between [A-Z]

- Has at least 1 number between [0-9]

- Has at least 1 caracter from [$#]

- Has minimum length of 6 characters

- Has maximum length of 16 characters

- Starts with an uppercase

- Ends with a digit

Solution


import re


print(\'Now accepting passwords (Between 6-12 characters long, \'
      \'with at least a cursive and a capital letter, a number and either $, #, or @): \')
accepted_passwords = []
passwords = [x for x in input().split(\', \')]
for p in passwords:
    if len(p) < 6 or len(p) > 12:
        continue # ignore this password basically and skip to next statement
    elif not re.search(\'[a-z]\', p):
        continue # if no expected character is present, continue program execution to next statement
    elif not re.search(\'[A-Z]\', p):
        continue # \\\\
    elif not re.search(\'[0-9]\', p):
        continue # \\\\
    elif not re.search(\'[$#@]\', p):
        continue # \\\\
    elif re.search(\'[\\s]\', p):
        continue # ignore whitespace and continue program execution
    else:
        pass      # if password has expected size and characters do nothing, then append to list
    accepted_passwords.append(p)


print(\', \'.join(accepted_passwords))

Write a python program to check the validity of password inputted by users. A pass word is valid if the following holds: - Has at least 1 letter between [a-z[ a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site