Advertisement
go6odn28

1_password_reset..

Mar 29th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. predefined_string = input()
  2. password = predefined_string
  3. while True:
  4.     data = input().split()
  5.     action = data[0]
  6.     if action == "Done":
  7.         break
  8.     if action == "TakeOdd":
  9.         new_password = ""
  10.         for index in range(len(password)):
  11.             if index % 2 != 0:
  12.                 new_password += password[index]
  13.         password = new_password
  14.         print(password)
  15.     elif action == "Cut":
  16.         index = int(data[1])
  17.         length = int(data[2])
  18.         substring = password[index:(index + length)]
  19.         if substring in password:
  20.             password = password.replace(substring, '', 1)
  21.         print(password)
  22.     elif action == "Substitute":
  23.         substring = data[1]
  24.         substitute = data[2]
  25.         if substring not in password:
  26.             print('Nothing to replace!')
  27.         else:
  28.             password = password.replace(substring, substitute)
  29.             print(password)
  30. print(f"Your password is: {password}")
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement