f | def beginning(word): | f | def beginning(word): |
| length = len(word) | | length = len(word) |
| symbol_count = length // 3 | | symbol_count = length // 3 |
| | | |
| match length % 3: | | match length % 3: |
| case 0: | | case 0: |
n | return word[0:symbol_count] | n | return word[:symbol_count] |
| case 1: | | case 1: |
n | return word[0:symbol_count] | n | return word[:symbol_count] |
| case 2: | | case 2: |
n | return word[0 : symbol_count + 1] | n | return word[: symbol_count + 1] |
| | | |
| def middle(word): | | def middle(word): |
| length = len(word) | | length = len(word) |
| symbol_count = length // 3 | | symbol_count = length // 3 |
| | | |
| match length % 3: | | match length % 3: |
| case 0: | | case 0: |
| return word[symbol_count : 2*symbol_count] | | return word[symbol_count : 2*symbol_count] |
| case 1: | | case 1: |
| return word[symbol_count : 2*symbol_count + 1] | | return word[symbol_count : 2*symbol_count + 1] |
| case 2: | | case 2: |
| return word[symbol_count + 1 : 2*symbol_count + 1] | | return word[symbol_count + 1 : 2*symbol_count + 1] |
| | | |
| def end(word): | | def end(word): |
| length = len(word) | | length = len(word) |
| symbol_count = length // 3 | | symbol_count = length // 3 |
| | | |
| match length % 3: | | match length % 3: |
| case 0: | | case 0: |
n | return word[2*symbol_count : length] | n | return word[2*symbol_count :] |
| case 1: | | case 1: |
n | return word[2*symbol_count + 1 : length] | n | return word[2*symbol_count + 1 :] |
| case 2: | | case 2: |
n | return word[2*symbol_count + 1 : length] | n | return word[2*symbol_count + 1 :] |
| | | |
| def split_sentence(sentence): | | def split_sentence(sentence): |
| splitted_list = [] | | splitted_list = [] |
t | splitted_str = str.split(sentence, ' ') | t | splitted_str = sentence.split() |
| | | |
| for word in splitted_str: | | for word in splitted_str: |
| splitted_list.append((beginning(word), middle(word), end(word))) | | splitted_list.append((beginning(word), middle(word), end(word))) |
| | | |
| return splitted_list | | return splitted_list |