Created
April 16, 2023 02:06
-
-
Save nobuh/4b98324112559776adb5e474f8a637a4 to your computer and use it in GitHub Desktop.
カンマ列挙リスト
This file contains 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 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