G2A Many GEOs
SHARE
TWEET

string manipulator

a guest Mar 31st, 2020 77 in 309 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. text = input()
  2. command = input()
  3.  
  4. while command != "End":
  5.     command = command.split(" ")
  6.  
  7.     if command[0] == "Translate":
  8.         char = command[1]
  9.         replacement = command[2]
  10.         text = text.replace(char, replacement)
  11.         print(text)
  12.  
  13.     elif command[0] == "Includes":
  14.         string = command[1]
  15.         if string in text:
  16.             print("True")
  17.         else:
  18.             print("False")
  19.  
  20.     elif command[0] == "Start":
  21.         string = command[1]
  22.         result = text.startswith(string)
  23.         print(result)
  24.  
  25.     elif command[0] == "Lowercase":
  26.         text = text.lower()
  27.         print(text)
  28.  
  29.     elif command[0] == "FindIndex":
  30.         char = command[1]
  31.         print(text.rfind(char))
  32.  
  33.     elif command[0] == "Remove":
  34.         start_index = int(command[1])
  35.         count = int(command[2])
  36.         substring = text[start_index:start_index + count]
  37.         text = text.replace(substring, "")
  38.         print(text)
  39.  
  40.     command = input()
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top