Skip to content

Instantly share code, notes, and snippets.

@Gwith
Created August 7, 2016 19:16
Show Gist options
  • Save Gwith/aded3af2828f2c4d5172cee3cb13ed60 to your computer and use it in GitHub Desktop.
Save Gwith/aded3af2828f2c4d5172cee3cb13ed60 to your computer and use it in GitHub Desktop.
spam = ['apples', 'bananas', 'tofu', 'cats']
def comma(a_list):
last = a_list[:-1]
all_but_last = a_list[0:-1]
result = ''
for item in all_but_last:
result += item
result += ','
print(result)
comma(spam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment