Advertisement
pacho_the_python

Untitled

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