Advertisement
Nenogzar

01. Password Reset 1

Mar 18th, 2024
1,606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. test_password = input()
  2. password = test_password
  3. command = input()
  4. while command != "Done":
  5.     command_part = command.split(" ")
  6.     if command_part[0] == "TakeOdd":
  7.         password = ''.join(password[i] for i in range(len(password)) if i % 2 != 0)
  8.         print(password)
  9.     elif command_part[0] == "Cut":
  10.         index, length = int(command_part[1]), int(command_part[2])
  11.         password = password[:index] + password[index + length:]
  12.         print(password)
  13.     elif command_part[0] == "Substitute":
  14.         substring, substitute_text = command_part[1], command_part[2]
  15.         if substring in password:
  16.             password = password.replace(substring, substitute_text)
  17.             print(password)
  18.         else:
  19.             print("Nothing to replace")
  20.  
  21.     command = input()
  22.  
  23. print(f"Your password is: {password}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement