Skip to content

Commit 3aea153

Browse files
committed
Raise ValueError for multi-character separators in split
1 parent 6c04620 commit 3aea153

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

strings/split.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ def split(string: str, separator: str = " ") -> list:
1717
1818
>>> split(";abbb;;c;", separator=';')
1919
['', 'abbb', '', 'c', '']
20+
21+
>>> split("a--b--c", separator="--")
22+
Traceback (most recent call last):
23+
...
24+
ValueError: Separator must be a single character
2025
"""
26+
if len(separator) != 1:
27+
raise ValueError("Separator must be a single character")
2128

2229
split_words = []
2330

0 commit comments

Comments
 (0)