How to generate "a, b, c, and d"?

Chris Angelico rosuav at gmail.com
Thu Dec 15 21:42:17 EST 2011


On Fri, Dec 16, 2011 at 11:57 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>  items[-1] = "and " + items[-1]
>  return ", ".join(items)

This works only if you're sure there are at least two items, and if
you don't mind two items coming out as "a, and b".

ChrisA



More information about the Python-list mailing list