Currently working my way through this beginners book and have completed one of the practice projects \'Comma Code\' which asks the user to construct a program which:
listA = [ 'apples', 'bananas', 'tofu' ]
def commaCode(listA):
s = ''
for items in listA:
if items == listA [0]:
s = listA[0]
elif items == listA[-1]:
s += ', and ' + items
else:
s += ', ' + items
return s
print(commaCode(listA))