Created
January 7, 2014 00:23
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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