Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions strings/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def split(string: str, separator: str = " ") -> list:

>>> split("12:43:39",separator = ":")
['12', '43', '39']

>>> split(";abbb;;c;", separator=';')
['', 'abbb', '', 'c', '']
"""

split_words = []
Expand All @@ -25,6 +28,10 @@ def split(string: str, separator: str = " ") -> list:
last_index = index + 1
elif index + 1 == len(string):
split_words.append(string[last_index : index + 1])

if string and string[-1] == separator:
split_words.append("")

return split_words


Expand Down
Loading