Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import string
- password = input(
- """
- Please enter your password.
- Passwords must be more than 10 characters long,
- But less than 20 characters long.
- include both upper and lower case letters
- and atleast 1 special character.
- password can contain no spaces.
- type password here:""")
- num_lowercase_letters = 0
- num_uppercase_letters = 0
- num_digits = 0
- num_special_characters = 0
- if not 10 <= len(password) <= 20:
- sys.exit("Password length not met, try again")
- for i in password:
- if i in string.ascii_lowercase:
- num_lowercase_letters += 1
- elif i in string.ascii_uppercase:
- num_uppercase_letters += 1
- elif i in string.digits:
- num_digits += 1
- elif i in string.punctuation:
- num_special_characters += 1
- elif i == " ":
- sys.exit("spaces are not allowed. Please try again.")
- else:
- sys.exit("One of your characters is not allowed. Please try again.")
- if num_lowercase_letters == 0:
- sys.exit("No lowercase letters detected, try again")
- if num_uppercase_letters == 0:
- sys.exit("No uppercase letters detected, try again")
- if num_digits == 0:
- sys.exit("No numbers detected, try again")
- if num_special_characters == 0:
- sys.exit("No special characters detected, try again")
- print("password setup complete. Password is %s" % (password))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement