mardi 3 juillet 2018

multiple if-statement password checker(python) [on hold]

This is the question:

A website requires the users to input username and password to register. Write a program to check the validity of password input by users.

Following are the criteria for checking the password:

  1. At least 1 letter between [a-z]
  2. At least 1 number between [0-9]
  3. At least 1 letter between [A-Z]
  4. At least 1 character from [$#@]
  5. Minimum length of transaction password: 6
  6. Maximum length of transaction password: 12

Your program should accept a sequence of comma-separated passwords and will check them according to the above criteria. Passwords that match the criteria are to be printed, each separated by a comma.

Example

input:

ABd1234@1,a F1#,2w3E*,2We3345

output:

ABd1234@1

my code (not complete!):

low_case = 'abcdefghijklmnopqrstuvwxyz'
up_case = low_case.upper()
nums = '1234567890'
chars = '!@#$%^&*()_+'

user_in = input('enter passwords: ')
user_in = user_in.replace(',',' ')
user_in = user_in.split()

accepted = list()


for pw in user_in:
    if 6 <= len(pw) <= 12:
        print('ok')

    else:
        print('wrong')

Aucun commentaire:

Enregistrer un commentaire