1def beginning(word):
2 '''Take a word and return the beggining of it.'''
3 leng = len(word) // 3
4 if len(word) % 3 == 2:
5 return word[:leng+1]
6 return word[:leng]
7
8def middle(word):
9 '''Take a word and return the middle part of it.'''
10 leng = len(word) // 3
11 if len(word) % 3 == 2:
12 return word[leng+1:len(word)-leng-1]
13 return word[leng:len(word)-leng]
14
15def end(word):
16 '''Take a word and return the end of it.'''
17 leng = len(word) // 3
18 if len(word) % 3 == 2:
19 return word[len(word)-leng-1:]
20 return word[len(word)-leng:]
21
22def split_sentence(sentence):
23 '''Take a sentence and return list of all words divided into 3 parts.'''
24 words = sentence.split()
25 result = []
26 for word in words:
27 result.append((beginning(word), middle(word), end(word)))
28 return result
............
----------------------------------------------------------------------
Ran 12 tests in 0.000s
OK
Амира Емин
15.10.2023 13:42Малко се обърках със сглобяването на кортежа, тъй като не го тествах предварително, и затова се получиха толкова много качени варианти
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
n | 2 | '''Take a word and return the beggining of it''' | n | 2 | '''Take a word and return the beggining of it.''' |
3 | leng = len(word) // 3 | 3 | leng = len(word) // 3 | ||
4 | if len(word) % 3 == 2: | 4 | if len(word) % 3 == 2: | ||
5 | return word[:leng+1] | 5 | return word[:leng+1] | ||
6 | return word[:leng] | 6 | return word[:leng] | ||
7 | 7 | ||||
8 | def middle(word): | 8 | def middle(word): | ||
n | 9 | '''Take a word and return the middle part of it''' | n | 9 | '''Take a word and return the middle part of it.''' |
10 | leng = len(word) // 3 | 10 | leng = len(word) // 3 | ||
11 | if len(word) % 3 == 2: | 11 | if len(word) % 3 == 2: | ||
12 | return word[leng+1:len(word)-leng-1] | 12 | return word[leng+1:len(word)-leng-1] | ||
13 | return word[leng:len(word)-leng] | 13 | return word[leng:len(word)-leng] | ||
14 | 14 | ||||
15 | def end(word): | 15 | def end(word): | ||
n | 16 | '''Take a word and return the end of it''' | n | 16 | '''Take a word and return the end of it.''' |
17 | leng = len(word) // 3 | 17 | leng = len(word) // 3 | ||
18 | if len(word) % 3 == 2: | 18 | if len(word) % 3 == 2: | ||
19 | return word[len(word)-leng-1:] | 19 | return word[len(word)-leng-1:] | ||
20 | return word[len(word)-leng:] | 20 | return word[len(word)-leng:] | ||
21 | 21 | ||||
22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
t | 23 | '''Take a sentence and return list of all words divided into 3 parts''' | t | 23 | '''Take a sentence and return list of all words divided into 3 parts.''' |
24 | words = sentence.split() | 24 | words = sentence.split() | ||
25 | result = [] | 25 | result = [] | ||
26 | for word in words: | 26 | for word in words: | ||
27 | result.append((beginning(word), middle(word), end(word))) | 27 | result.append((beginning(word), middle(word), end(word))) | ||
28 | return result | 28 | return result |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
2 | '''Take a word and return the beggining of it''' | 2 | '''Take a word and return the beggining of it''' | ||
3 | leng = len(word) // 3 | 3 | leng = len(word) // 3 | ||
4 | if len(word) % 3 == 2: | 4 | if len(word) % 3 == 2: | ||
5 | return word[:leng+1] | 5 | return word[:leng+1] | ||
6 | return word[:leng] | 6 | return word[:leng] | ||
7 | 7 | ||||
8 | def middle(word): | 8 | def middle(word): | ||
9 | '''Take a word and return the middle part of it''' | 9 | '''Take a word and return the middle part of it''' | ||
10 | leng = len(word) // 3 | 10 | leng = len(word) // 3 | ||
11 | if len(word) % 3 == 2: | 11 | if len(word) % 3 == 2: | ||
12 | return word[leng+1:len(word)-leng-1] | 12 | return word[leng+1:len(word)-leng-1] | ||
13 | return word[leng:len(word)-leng] | 13 | return word[leng:len(word)-leng] | ||
14 | 14 | ||||
15 | def end(word): | 15 | def end(word): | ||
16 | '''Take a word and return the end of it''' | 16 | '''Take a word and return the end of it''' | ||
17 | leng = len(word) // 3 | 17 | leng = len(word) // 3 | ||
18 | if len(word) % 3 == 2: | 18 | if len(word) % 3 == 2: | ||
19 | return word[len(word)-leng-1:] | 19 | return word[len(word)-leng-1:] | ||
20 | return word[len(word)-leng:] | 20 | return word[len(word)-leng:] | ||
21 | 21 | ||||
22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
23 | '''Take a sentence and return list of all words divided into 3 parts''' | 23 | '''Take a sentence and return list of all words divided into 3 parts''' | ||
24 | words = sentence.split() | 24 | words = sentence.split() | ||
25 | result = [] | 25 | result = [] | ||
26 | for word in words: | 26 | for word in words: | ||
27 | result.append((beginning(word), middle(word), end(word))) | 27 | result.append((beginning(word), middle(word), end(word))) | ||
28 | return result | 28 | return result | ||
t | 29 | t | |||
30 | print(split_sentence("Hello mine nesso")) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
2 | '''Take a word and return the beggining of it''' | 2 | '''Take a word and return the beggining of it''' | ||
3 | leng = len(word) // 3 | 3 | leng = len(word) // 3 | ||
4 | if len(word) % 3 == 2: | 4 | if len(word) % 3 == 2: | ||
5 | return word[:leng+1] | 5 | return word[:leng+1] | ||
6 | return word[:leng] | 6 | return word[:leng] | ||
7 | 7 | ||||
8 | def middle(word): | 8 | def middle(word): | ||
9 | '''Take a word and return the middle part of it''' | 9 | '''Take a word and return the middle part of it''' | ||
10 | leng = len(word) // 3 | 10 | leng = len(word) // 3 | ||
11 | if len(word) % 3 == 2: | 11 | if len(word) % 3 == 2: | ||
12 | return word[leng+1:len(word)-leng-1] | 12 | return word[leng+1:len(word)-leng-1] | ||
13 | return word[leng:len(word)-leng] | 13 | return word[leng:len(word)-leng] | ||
14 | 14 | ||||
15 | def end(word): | 15 | def end(word): | ||
16 | '''Take a word and return the end of it''' | 16 | '''Take a word and return the end of it''' | ||
17 | leng = len(word) // 3 | 17 | leng = len(word) // 3 | ||
18 | if len(word) % 3 == 2: | 18 | if len(word) % 3 == 2: | ||
19 | return word[len(word)-leng-1:] | 19 | return word[len(word)-leng-1:] | ||
20 | return word[len(word)-leng:] | 20 | return word[len(word)-leng:] | ||
21 | 21 | ||||
22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
23 | '''Take a sentence and return list of all words divided into 3 parts''' | 23 | '''Take a sentence and return list of all words divided into 3 parts''' | ||
24 | words = sentence.split() | 24 | words = sentence.split() | ||
25 | result = [] | 25 | result = [] | ||
26 | for word in words: | 26 | for word in words: | ||
n | 27 | result.append(beginning(word), middle(word), end(word)) | n | 27 | result.append((beginning(word), middle(word), end(word))) |
28 | return result | 28 | return result | ||
t | t | 29 | |||
30 | print(split_sentence("Hello mine nesso")) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
2 | '''Take a word and return the beggining of it''' | 2 | '''Take a word and return the beggining of it''' | ||
3 | leng = len(word) // 3 | 3 | leng = len(word) // 3 | ||
4 | if len(word) % 3 == 2: | 4 | if len(word) % 3 == 2: | ||
5 | return word[:leng+1] | 5 | return word[:leng+1] | ||
6 | return word[:leng] | 6 | return word[:leng] | ||
7 | 7 | ||||
8 | def middle(word): | 8 | def middle(word): | ||
9 | '''Take a word and return the middle part of it''' | 9 | '''Take a word and return the middle part of it''' | ||
10 | leng = len(word) // 3 | 10 | leng = len(word) // 3 | ||
11 | if len(word) % 3 == 2: | 11 | if len(word) % 3 == 2: | ||
12 | return word[leng+1:len(word)-leng-1] | 12 | return word[leng+1:len(word)-leng-1] | ||
13 | return word[leng:len(word)-leng] | 13 | return word[leng:len(word)-leng] | ||
14 | 14 | ||||
15 | def end(word): | 15 | def end(word): | ||
16 | '''Take a word and return the end of it''' | 16 | '''Take a word and return the end of it''' | ||
17 | leng = len(word) // 3 | 17 | leng = len(word) // 3 | ||
18 | if len(word) % 3 == 2: | 18 | if len(word) % 3 == 2: | ||
19 | return word[len(word)-leng-1:] | 19 | return word[len(word)-leng-1:] | ||
20 | return word[len(word)-leng:] | 20 | return word[len(word)-leng:] | ||
21 | 21 | ||||
22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
23 | '''Take a sentence and return list of all words divided into 3 parts''' | 23 | '''Take a sentence and return list of all words divided into 3 parts''' | ||
24 | words = sentence.split() | 24 | words = sentence.split() | ||
25 | result = [] | 25 | result = [] | ||
26 | for word in words: | 26 | for word in words: | ||
t | 27 | result.append(tuple(beginning(word), middle(word), end(word))) | t | 27 | result.append(beginning(word), middle(word), end(word)) |
28 | return result | 28 | return result |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | def beginning(word): | f | 1 | def beginning(word): |
n | 2 | '''Takes a word and returns the beggining of it''' | n | 2 | '''Take a word and return the beggining of it''' |
3 | leng = len(word) // 3 | 3 | leng = len(word) // 3 | ||
4 | if len(word) % 3 == 2: | 4 | if len(word) % 3 == 2: | ||
5 | return word[:leng+1] | 5 | return word[:leng+1] | ||
6 | return word[:leng] | 6 | return word[:leng] | ||
7 | 7 | ||||
8 | def middle(word): | 8 | def middle(word): | ||
n | 9 | '''Takes a word and returns the middle part of it''' | n | 9 | '''Take a word and return the middle part of it''' |
10 | leng = len(word) // 3 | 10 | leng = len(word) // 3 | ||
11 | if len(word) % 3 == 2: | 11 | if len(word) % 3 == 2: | ||
12 | return word[leng+1:len(word)-leng-1] | 12 | return word[leng+1:len(word)-leng-1] | ||
13 | return word[leng:len(word)-leng] | 13 | return word[leng:len(word)-leng] | ||
14 | 14 | ||||
15 | def end(word): | 15 | def end(word): | ||
n | 16 | '''Takes a word and returns the end of it''' | n | 16 | '''Take a word and return the end of it''' |
17 | leng = len(word)//3 | 17 | leng = len(word) // 3 | ||
18 | if len(word) % 3 == 2: | 18 | if len(word) % 3 == 2: | ||
19 | return word[len(word)-leng-1:] | 19 | return word[len(word)-leng-1:] | ||
20 | return word[len(word)-leng:] | 20 | return word[len(word)-leng:] | ||
21 | 21 | ||||
22 | def split_sentence(sentence): | 22 | def split_sentence(sentence): | ||
n | 23 | '''Takes a sentence and returns a list of tuples that represent all | n | 23 | '''Take a sentence and return list of all words divided into 3 parts''' |
24 | the words in the sentence splitted in three "equal" parts - | ||||
25 | beginning, middle part and the end of the word''' | ||||
26 | arr = sentence.split() | 24 | words = sentence.split() | ||
27 | result = [] | 25 | result = [] | ||
t | 28 | for word in arr: | t | 26 | for word in words: |
29 | syllables = [] | 27 | result.append(tuple(beginning(word), middle(word), end(word))) | ||
30 | syllables.append(beginning(word)) | ||||
31 | syllables.append(middle(word)) | ||||
32 | syllables.append(end(word)) | ||||
33 | result.append(tuple(syllables)) | ||||
34 | return result | 28 | return result |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|