What is an elegant way to join a list of sentence parts so that the result is \"a, b, and c\" where the list is [ \'a\', \'b\', \'c\' ]? Specifying
list
[ \'a\', \'b\', \'c\' ]
l = ['a','b','c'] if len(l) > 1: print ",".join(k[:-1]) + " and " + k[-1] else:print l[0]
exapmles:
l = ['a','b','c'] a,b and c l = ['a','b'] a and b l=['a'] a