From 3aea153877d008385a48416fdc5cca4802f4e465 Mon Sep 17 00:00:00 2001 From: Priyanshu1x Date: Mon, 15 Jun 2026 12:34:12 +0530 Subject: [PATCH] Raise ValueError for multi-character separators in split --- strings/split.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/strings/split.py b/strings/split.py index ed194ec69c2f..0047ff68e55a 100644 --- a/strings/split.py +++ b/strings/split.py @@ -17,7 +17,14 @@ 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 = []