Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Created September 1, 2013 14:11
Show Gist options
  • Save 23maverick23/6404685 to your computer and use it in GitHub Desktop.
Save 23maverick23/6404685 to your computer and use it in GitHub Desktop.
Python: Convert a set, tuple or list into a comma separated string.
# create a new set and add values
myset = set()
myset.add(1)
myset.add(2)
myset.add(4)
# by default, a set returns a set Object
# myset = set([1, 2, 4])
# use join() to parse the List into a str
','.join(str(s) for s in myset)
'1,2,4'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment