Advertisement
ChynaBG

String Manipulator 1

Mar 31st, 2020
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. text = input()
  2. com = input()
  3.  
  4. while com != 'End':
  5.     tokens = com.split(' ')
  6.     command = tokens[0]
  7.     if command == 'Translate':
  8.         char = tokens[1]
  9.         replacement = tokens[2]
  10.         text = text.replace(char, replacement)
  11.         print(text)
  12.     elif command == 'Includes':
  13.         string = tokens[1]
  14.         if string in text:
  15.             print('True')
  16.         else:
  17.             print('False')
  18.     elif command == 'Start':
  19.         start = tokens[1]
  20.         print(text.startswith(start))
  21.     elif command == 'Lowercase':
  22.         text = text.lower()
  23.         print(text)
  24.     elif command == 'FindIndex':
  25.         char = tokens[1]
  26.         print(text.rfind(char))
  27.     elif command == 'Remove':
  28.         start = int(tokens[1])
  29.         count = int(tokens[2])
  30.         text = text[start + count:]
  31.         print(text)
  32.     com = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement