Skip to content

Commit d556865

Browse files
committed
fix: raise ValueError for multi-character separator in split
Fixes #14649 Signed-off-by: SAY-5 <say.apm35@gmail.com>
1 parent 791deb4 commit d556865

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)