Swarms / swarms /structs /concat.py
harshalmore31's picture
Synced repo using 'sync_with_huggingface' Github Action
d8d14f1 verified
raw
history blame contribute delete
732 Bytes
from typing import List
def concat_strings(string_list: List[str]) -> str:
"""
Concatenates a list of strings into a single string.
Args:
string_list (List[str]): A list of strings to be concatenated.
Returns:
str: The concatenated string.
Raises:
TypeError: If the input is not a list of strings.
"""
if not isinstance(string_list, list):
raise TypeError("Input must be a list of strings.")
if not all(isinstance(string, str) for string in string_list):
raise TypeError("All elements in the list must be strings.")
try:
return "".join(string_list)
except TypeError:
raise TypeError("All elements in the list must be strings.")