Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exp = input()
- cmd = input()
- while cmd != "Finish":
- cmd = cmd.split(" ")
- if cmd[0] == "Replace":
- cur = cmd[1]
- new = cmd[2]
- exp = exp.replace(cur, new, exp.find(cur))
- print(exp)
- if cmd[0] == "Cut":
- startIdx = int(cmd[1])
- endIdx = int(cmd[2])
- if 0 <= startIdx <= endIdx < len(exp):
- removeString = exp[startIdx:endIdx + 1]
- exp = exp.replace(removeString, "")
- print(exp)
- else:
- print("Invalid indexes!")
- if cmd[0] == "Make":
- if cmd[1] == "Upper":
- exp = exp.upper()
- else:
- exp = exp.lower()
- print(exp)
- if cmd[0] == "Check":
- contains = cmd[1]
- if contains in exp:
- print(f"Message contains {contains}")
- else:
- print(f"Message doesn't contain {contains}")
- if cmd[0] == "Sum":
- startIdx = int(cmd[1])
- endIdx = int(cmd[2])
- if 0 <= startIdx <= endIdx < len(exp):
- string = exp[startIdx:endIdx + 1]
- sum = 0
- for char in string:
- sum += ord(char)
- print(sum)
- else:
- print("Invalid indexes!")
- cmd = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement