Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def replace_char(change_from, change_to, my_string):
- return my_string.replace(change_from, change_to)
- def include_substring(substring, my_string):
- return substring in my_string
- def ends_with_substring(substring, my_string):
- return my_string.endswith(substring)
- def upper_case(my_string):
- return my_string.upper()
- def find_first_idx(ch, my_string):
- return my_string.index(ch)
- def cut_part_of_string(start, end, my_string):
- return my_string[start:start + end]
- string = input()
- while True:
- line = input().split()
- command = line[0]
- if command == 'Done':
- break
- if command == 'Change':
- string = replace_char(line[1], line[2], string)
- print(string)
- elif command == 'Includes':
- print(include_substring(line[1], string))
- elif command == 'End':
- print(ends_with_substring(line[1], string))
- elif command == 'Uppercase':
- string = upper_case(string)
- print(string)
- elif command == 'FindIndex':
- print(find_first_idx(line[1], string))
- elif command == 'Cut':
- string = cut_part_of_string(int(line[1]), int(line[2]), string)
- print(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement