Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e60c15f

Browse files
authoredDec 29, 2024··
Update join.py
1 parent 4ef69c8 commit e60c15f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed
 

‎strings/join.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ def join(separator: str, separated: list[str]) -> str:
2020
'abcd'
2121
>>> join("#", ["a", "b", "c", "d"])
2222
'a#b#c#d'
23-
>>> join("#", "a") # Single string instead of list
24-
Traceback (most recent call last):
25-
...
26-
Exception: join() accepts only strings
23+
>>> join("#", "a")
24+
'a'
2725
>>> join(" ", ["You", "are", "amazing!"])
2826
'You are amazing!'
2927
>>> join(",", ["", "", ""])
@@ -35,10 +33,10 @@ def join(separator: str, separated: list[str]) -> str:
3533
Traceback (most recent call last):
3634
...
3735
Exception: join() accepts only strings
36+
37+
Additional test case with a different separator:
3838
>>> join("-", ["apple", "banana", "cherry"])
3939
'apple-banana-cherry'
40-
>>> join(",", ["", "", ""])
41-
',,'
4240
"""
4341

4442
# Check that all elements are strings

0 commit comments

Comments
 (0)
Please sign in to comment.