Is there a commas-in-between idiom?

Peter Otten __peter__ at web.de
Sun Nov 5 14:02:36 CET 2006


Ernesto García García wrote:

> it's very common that I have a list and I want to print it with commas
> in between. How do I do this in an easy manner, whithout having the
> annoying comma in the end?

>>> items = [1, 2, 3, "many"]
>>> print ", ".join(str(item) for item in items)
1, 2, 3, many

Peter



More information about the Python-list mailing list