Skip to content

Instantly share code, notes, and snippets.

@EricaJoy
Created January 7, 2014 00:23
Show Gist options
  • Save EricaJoy/8292555 to your computer and use it in GitHub Desktop.
Save EricaJoy/8292555 to your computer and use it in GitHub Desktop.
Turn a list into a comma separated string with an and for the last item. Oxford comma represent.
def stringmaker(startlist):
result = startlist[0]
for i in range(1,len(startlist)-1):
result = ', '.join([result,startlist[i]])
result = ', and '.join([result,startlist[len(startlist)-1]])
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment