Skip to content

Instantly share code, notes, and snippets.

@nobuh
Created April 16, 2023 02:06
Show Gist options
  • Save nobuh/4b98324112559776adb5e474f8a637a4 to your computer and use it in GitHub Desktop.
Save nobuh/4b98324112559776adb5e474f8a637a4 to your computer and use it in GitHub Desktop.
カンマ列挙リスト
def commalist(str):
listed = str[0]
for s in str[1:len(str)-1]:
listed = listed + ', ' + s
return listed + ' and ' + str[len(str)-1]
print(commalist(['apple', 'banana', 'tofu', 'cats']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment