Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- password = input()
- command = input()
- while not command == 'Complete':
- data = command.split()
- action = data[0]
- if action == "Make" and data[1] == 'Upper':
- index = int(data[2])
- password = password[:index] + password[index].upper() + password[index + 1:]
- print(password)
- elif action == "Make" and data[1] == 'Lower':
- index = int(data[2])
- password = password[:index] + password[index].lower() + password[index + 1:]
- print(password)
- elif action == "Insert":
- index = int(data[1])
- char = data[2]
- if 0 <= index < len(password):
- password = password[:index] + char + password[index:]
- print(password)
- elif action == "Replace":
- char = data[1]
- value = int(data[2])
- if char in password:
- new = ord(char) + value
- password = password.replace(char, chr(new))
- print(password)
- elif action == "Validation":
- upper_count = 0
- lower_count = 0
- digit_count = 0
- others = 0
- for a in password:
- if not a.isdigit() and not a.isalpha() and not a == "_":
- others += 1
- elif a.isupper():
- upper_count += 1
- elif a.islower():
- lower_count += 1
- elif a.isdigit():
- digit_count += 1
- if len(password) < 8:
- print(f"Password must be at least 8 characters long!")
- if others > 0:
- print("Password must consist only of letters, digits and _!")
- if upper_count == 0:
- print("Password must consist at least one uppercase letter!")
- if lower_count == 0:
- print("Password must consist at least one lowercase letter!")
- if digit_count == 0:
- print("Password must consist at least one digit!")
- command = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement