Advertisement
George_Ivanov05

0.1

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