Skip to content

Commit 4ef69c8

Browse files
Update join.py
1 parent 06bd5cd commit 4ef69c8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

strings/join.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
"""
2+
Program to join a list of strings with a separator
3+
"""
4+
5+
16
def join(separator: str, separated: list[str]) -> str:
27
"""
3-
Custom implementation of the join() function.
4-
This function manually concatenates the strings in the list,
5-
using the provided separator, without relying on str.join().
8+
Joins a list of strings using a separator
9+
and returns the result.
610
7-
:param separator: The separator to place between strings.
8-
:param separated: A list of strings to join.
11+
:param separator: Separator to be used
12+
for joining the strings.
13+
:param separated: List of strings to be joined.
914
10-
:return: A single string with elements joined by the separator.
11-
12-
:raises Exception: If any element in the list is not a string.
15+
:return: Joined string with the specified separator.
1316
1417
Examples:
18+
1519
>>> join("", ["a", "b", "c", "d"])
1620
'abcd'
1721
>>> join("#", ["a", "b", "c", "d"])

0 commit comments

Comments
 (0)