Advertisement
horozov86

Password Reset

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