File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -21,17 +21,23 @@ def split(string: str, separator: str = " ") -> list:
21
21
22
22
for index , char in enumerate (string ):
23
23
if char == separator :
24
- split_words .append (string [last_index :index ]) # Add substring between separators
24
+ split_words .append (
25
+ string [last_index :index ]
26
+ ) # Add substring between separators
25
27
last_index = index + 1
26
- elif index + 1 == len (string ): # If at the last character, handle trailing separator
28
+ elif index + 1 == len (
29
+ string
30
+ ): # If at the last character, handle trailing separator
27
31
split_words .append (string [last_index :]) # Add the last part of the string
28
32
29
33
# If the string ends with a separator, ensure an empty string is added
30
34
if string and string [- 1 ] == separator :
31
- split_words .append ('' )
35
+ split_words .append ("" )
32
36
33
37
return split_words
34
38
39
+
35
40
if __name__ == "__main__" :
36
41
from doctest import testmod
42
+
37
43
testmod ()
You can’t perform that action at this time.
0 commit comments