How to join entries in a set into one string?
', '.join(set_3)
The join
is a string method, not a set method.
Sets don't have a join
method but you can use str.join
instead.
', '.join(set_3)
The str.join
method will work on any iterable object including lists and sets.
Note: be careful about using this on sets containing integers; you will need to convert the integers to strings before the call to join. For example
set_4 = {1, 2}
', '.join(str(s) for s in set_4)