On Wed, Jul 09, 2008 at 10:25:33PM +0200, Michiel Overtoom wrote: > Formatting a sequence of items such that they are separated by > commas, except the last item, which is separated by the word 'and'. > > For example: > > Three friends have a dinner: Anne, Bob and Chris
row = ["Anne","Bob","Chris"] txt = ", ".join(row) pos = txt.rfind(", ") new = "%s and %s" % (txt[0:pos], txt[pos+2:]) egbert -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== -- http://mail.python.org/mailman/listinfo/python-list