On Wed, Jul 09, 2008 at 10:25:33PM +0200, Michiel Overtoom wrote:
row = ["Anne","Bob","C hris"]
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
=============== =============== =============== =============== ============
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
commas, except the last item, which is separated by the word 'and'.
>
For example:
>
Three friends have a dinner: Anne, Bob and 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
=============== =============== =============== =============== ============