program to join a list of strings with a separator joins a list of strings using a separator and returns the result param separator separator to be used for joining the strings param separated list of strings to be joined return joined string with the specified separator examples join a b c d abcd join a b c d abcd join a a join you are amazing you are amazing this example should raise an exception for nonstring elements join a b c 1 traceback most recent call last exception join accepts only strings additional test case with a different separator join apple banana cherry applebananacherry remove the trailing separator by stripping it from the result joins a list of strings using a separator and returns the result param separator separator to be used for joining the strings param separated list of strings to be joined return joined string with the specified separator examples join a b c d abcd join a b c d a b c d join a a join you are amazing you are amazing this example should raise an exception for non string elements join a b c 1 traceback most recent call last exception join accepts only strings additional test case with a different separator join apple banana cherry apple banana cherry remove the trailing separator by stripping it from the result
def join(separator: str, separated: list[str]) -> str:
    

    joined = ""
    for word_or_phrase in separated:
        if not isinstance(word_or_phrase, str):
            raise Exception("join() accepts only strings")
        joined += word_or_phrase + separator

    
    
    return joined.strip(separator)


if __name__ == "__main__":
    from doctest import testmod

    testmod()