Advertisement
bl00dt3ars

Untitled

Aug 20th, 2021 (edited)
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. password = input()
  2. command = input()
  3.  
  4. while not command == 'Complete':
  5.     data = command.split()
  6.     action = data[0]
  7.     if action == "Make" and data[1] == 'Upper':
  8.         index = int(data[2])
  9.         password = password[:index] + password[index].upper() + password[index + 1:]
  10.         print(password)
  11.     elif action == "Make" and data[1] == 'Lower':
  12.         index = int(data[2])
  13.         password = password[:index] + password[index].lower() + password[index + 1:]
  14.         print(password)
  15.     elif action == "Insert":
  16.         index = int(data[1])
  17.         char = data[2]
  18.         if 0 <= index < len(password):
  19.             password = password[:index] + char + password[index:]
  20.             print(password)
  21.     elif action == "Replace":
  22.         char = data[1]
  23.         value = int(data[2])
  24.         if char in password:
  25.             new = ord(char) + value
  26.             password = password.replace(char, chr(new))
  27.         print(password)
  28.     elif action == "Validation":
  29.         upper_count = 0
  30.         lower_count = 0
  31.         digit_count = 0
  32.         others = 0
  33.         for a in password:
  34.             if not a.isdigit() and not a.isalpha() and not a == "_":
  35.                 others += 1
  36.             elif a.isupper():
  37.                 upper_count += 1
  38.             elif a.islower():
  39.                 lower_count += 1
  40.             elif a.isdigit():
  41.                 digit_count += 1
  42.  
  43.         if len(password) < 8:
  44.             print(f"Password must be at least 8 characters long!")
  45.         if others > 0:
  46.             print("Password must consist only of letters, digits and _!")
  47.         if upper_count == 0:
  48.             print("Password must consist at least one uppercase letter!")
  49.         if lower_count == 0:
  50.             print("Password must consist at least one lowercase letter!")
  51.         if digit_count == 0:
  52.             print("Password must consist at least one digit!")
  53.  
  54.     command = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement