Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created October 18, 2011 02:41
Show Gist options
  • Save lxneng/1294488 to your computer and use it in GitHub Desktop.
Save lxneng/1294488 to your computer and use it in GitHub Desktop.
Separate a list to a comma-separated sentence
def textList(listtext, sep1=', ', sep2=', and '):
return sep1.join(listtext[:-2]+['']) + sep2.join(listtext[-2:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment