Basically, I am trying to join together the entries in a set in order to output one string. I am trying to use syntax similar to the join function for lists. Here is my atte
I wrote a method that handles the following edge-cases:
", ".join({'abc'}) will return "a, b, c". My desired output was "abc".""def set_to_str(set_to_convert, separator=", "):
set_size = len(set_to_convert)
if not set_size:
return ""
elif set_size == 1:
(element,) = set_to_convert
return str(element)
else:
return separator.join(map(str, set_to_convert))