yordan_yordanov

P1

Dec 13th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. text = input()
  2. command = input()
  3.  
  4. while not command == "Done":
  5. tokens = command.split()
  6. current_command = tokens[0]
  7.  
  8. if current_command == "Change":
  9. char = tokens[1]
  10. replacement = tokens[2]
  11. text = text.replace(char, replacement)
  12. print(text)
  13.  
  14. elif current_command == "Includes":
  15. result = tokens[1] in text
  16. print(result)
  17.  
  18. elif current_command == "End":
  19. string = tokens[1]
  20. result = text.endswith(string)
  21. print(result)
  22.  
  23. elif current_command == "Uppercase":
  24. text = text.upper()
  25. print(text)
  26.  
  27. elif current_command == "FindIndex":
  28. char = tokens[1]
  29. index = text.index(char)
  30. print(index)
  31.  
  32. elif current_command == "Cut":
  33. start_index = int(tokens[1])
  34. length = int(tokens[2])
  35. text = text[start_index:start_index+length]
  36. print(text)
  37.  
  38. command = input()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment