1def beginning(word):
2 remainder = len(word) % 3
3 addition = remainder and remainder % 2 == 0
4 end = len(word) // 3 + addition
5
6 return word[:end]
7
8def middle(word):
9 remainder = len(word) % 3
10 addition = remainder and remainder % 2 == 0
11 start = len(word) // 3 + addition
12 end = len(word) - len(word) // 3 - addition
13
14 return word[start:end]
15
16def end(word):
17 remainder = len(word) % 3
18 addition = remainder and remainder % 2 == 0
19 start = len(word) - len(word) // 3 - addition
20
21 return word[start:]
22
23def split_sentence(sentence):
24 result = []
25 sentence = sentence.split()
26
27 for word in sentence:
28 result.append((beginning(word), middle(word), end(word)))
29
30 return result
............
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
15.10.2023 11:36