File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 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:
2121
2222 for index , char in enumerate (string ):
2323 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
2527 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
2731 split_words .append (string [last_index :]) # Add the last part of the string
2832
2933 # If the string ends with a separator, ensure an empty string is added
3034 if string and string [- 1 ] == separator :
31- split_words .append ('' )
35+ split_words .append ("" )
3236
3337 return split_words
3438
39+
3540if __name__ == "__main__" :
3641 from doctest import testmod
42+
3743 testmod ()
You can’t perform that action at this time.
0 commit comments