Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- password = input()
- command_data = input()
- while not command_data == "Complete":
- curr_data = command_data.split()
- command = curr_data[0]
- if command == "Make":
- if curr_data[1] == "Upper":
- index = int(curr_data[2])
- new_password = ""
- for current_index, char in enumerate(password):
- if current_index == index:
- new_password += char.upper()
- else:
- new_password += char
- password = new_password
- print(password)
- elif curr_data[1] == "Lower":
- index = int(curr_data[2])
- new_password = ""
- for current_index, char in enumerate(password):
- if current_index == index:
- new_password += char.lower()
- else:
- new_password += char
- password = new_password
- print(password)
- elif command == "Insert":
- index = int(curr_data[1])
- char = curr_data[2]
- if index in range(len(password)):
- password = password[:index] + char + password[index:]
- print(password)
- elif command == "Replace":
- char = curr_data[1]
- value = int(curr_data[2])
- if char in password:
- password = password.replace(char, chr(ord(char) + value))
- print(password)
- elif command == "Validation":
- if len(password) < 8:
- print("Password must be at least 8 characters long!")
- for ch in password:
- if not ch.isalnum() and not ch == "_":
- print("Password must consist only of letters, digits and _!")
- break
- upper_counter = 0
- lower_counter = 0
- digit_counter = 0
- for ch in password:
- if ch.isupper():
- upper_counter += 1
- elif ch.islower():
- lower_counter += 1
- elif ch.isdigit():
- digit_counter += 1
- if upper_counter == 0:
- print("Password must consist at least one uppercase letter!")
- if lower_counter == 0:
- print("Password must consist at least one lowercase letter!")
- if digit_counter == 0:
- print("Password must consist at least one digit!")
- command_data = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement