Advertisement
go6odn28

password_reset_100/100

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