1def beginning(word):
2 length = len(word)
3 num = length % 3
4 if num == 0 or num == 1:
5 return word[:int(length / 3)]
6 else:
7 return word[:int(length / 3 + 1)]
8
9def middle(word):
10 length = len(word)
11 if length % 3 == 0:
12 return word[int(length / 3):int((length / 3) * 2)]
13 elif length % 3 == 2:
14 return word[int(length / 3 + 1):int(length / 3 + length / 3)]
15 else:
16 return word[int(length / 3):int((length / 3) * 2 + 1)]
17
18
19def end(word):
20 length = len(word)
21 if length % 3 == 0:
22 return word[int((length / 3) * 2):]
23 elif length%3==1:
24 return word[int((length / 3) * 2 )+1:]
25 else:
26 return word[int((length / 3) * 2 ):]
27
28def split_sentence(sentence):
29 words=sentence.split()
30 result=[]
31 for word in words:
32 result.append((beginning(word),middle(word),end(word)))
33 return result
............
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
17.10.2023 08:58
17.10.2023 09:02
17.10.2023 09:03
17.10.2023 09:03