Advertisement
TTpocToXaKep

Password strong check

Jan 31st, 2023
1,134
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 1 0
  1. # https://pastebin.com/u/TTpocToXaKep
  2.  
  3. password = input("Please enter your password: ")
  4.  
  5. # set the min length
  6. min_length = 8
  7.  
  8. # set the required conditions
  9. has_upper_case = False
  10. has_lower_case = False
  11. has_digit = False
  12.  
  13. # check the lenght of the password
  14. if len(password) >= min_length:
  15.  
  16.     # check for upper case
  17.     for char in password:
  18.         if char.isupper():
  19.             has_upper_case = True
  20.             break
  21.  
  22.     # check for lower case
  23.     for char in password:
  24.         if char.islower():
  25.             has_lower_case = True
  26.             break
  27.  
  28.     # check for digit
  29.     for char in password:
  30.         if char.isdigit():
  31.             has_digit = True
  32.             break
  33.  
  34. if has_upper_case and has_lower_case and has_digit and len(password) >= min_length:
  35.     print("Password is strong")
  36.     input("") # waiting exit
  37. else:
  38.     print("Password is not strong")
  39.     input("") # waiting exit
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement