From 26a8d7c26b8a3a7b66b4f4da818059d097b59a58 Mon Sep 17 00:00:00 2001 From: prantikmedhi <140103052+prantikmedhi@users.noreply.github.com> Date: Wed, 13 May 2026 20:46:47 +0530 Subject: [PATCH] fix(strings): reject multi-char split separators --- strings/split.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/strings/split.py b/strings/split.py index ed194ec69c2f..4a7f5b669645 100644 --- a/strings/split.py +++ b/strings/split.py @@ -17,8 +17,15 @@ def split(string: str, separator: str = " ") -> list: >>> split(";abbb;;c;", separator=';') ['', 'abbb', '', 'c', ''] + + >>> split("a--b--c", separator="--") + Traceback (most recent call last): + ValueError: separator must be a single character """ + if len(separator) != 1: + raise ValueError("separator must be a single character") + split_words = [] last_index = 0