Advertisement
pacho_the_python

task 1

Dec 3rd, 2023
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. some_string = input()
  2.  
  3. command_data = input().split()
  4.  
  5. while True:
  6.     command = command_data[0]
  7.     if command == "End":
  8.         break
  9.  
  10.     if command == "Translate":
  11.         char = command_data[1]
  12.         replacement = command_data[2]
  13.         some_string = some_string.replace(char, replacement)
  14.         print(some_string)
  15.  
  16.     elif command == "Includes":
  17.         substring = command_data[1]
  18.         if substring in some_string:
  19.             print("True")
  20.         else:
  21.             print("False")
  22.     elif command == "Start":
  23.         key_list = []
  24.         start_string = command_data[1]
  25.         match = False
  26.         for i in range(len(start_string)):
  27.             if start_string[i] == some_string[i]:
  28.                 match = True
  29.             else:
  30.                 match = False
  31.                 break
  32.         if match:
  33.             print("True")
  34.         else:
  35.             print("False")
  36.  
  37.     elif command == "Lowercase":
  38.         some_string = some_string.lower()
  39.         print(some_string)
  40.     elif command == "FindIndex":
  41.         last_symbol = command_data[1]
  42.         index = some_string.rfind(last_symbol)
  43.         print(index)
  44.     elif command == "Remove":
  45.         start_index = int(command_data[1])
  46.         num = int(command_data[2])
  47.         some_list = [y for y in some_string]
  48.  
  49.         counter = 0
  50.         for i in range(len(some_list)):
  51.             if counter == num:
  52.                 break
  53.             some_list.pop(start_index)
  54.             counter += 1
  55.         print("".join(some_list))
  56.     command_data = input().split()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement