Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def take_odd(password):
- return ''.join(password[i] for i in range(len(password)) if i % 2 != 0)
- def cut_password(password, index, length):
- return password[:index] + password[index+length:]
- def substitute_password(password, substring, substitute):
- if substring in password:
- return password.replace(substring, substitute)
- else:
- return "Nothing to replace!"
- def process(test_password):
- password = test_password
- command = input()
- while command != "Done":
- command_part = command.split(" ")
- if command_part[0] == "TakeOdd":
- password = take_odd(password)
- print(password)
- elif command_part[0] == "Cut":
- index, length = command_part[1], command_part[2]
- password = cut_password(password, int(index), int(length))
- print(password)
- elif command_part[0] == "Substitute":
- substring, substitute_text = command_part[1], command_part[2]
- password = substitute_password(password, substring, substitute_text)
- print(password)
- command = input()
- print(f"Your password is: {password}")
- if __name__ == "__main__":
- test_password = input()
- process(test_password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement