?
=?ISO-8859-1?Q?Ernesto_Garc=EDa_Garc=EDa?=
Hi experts,
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?
<code>
list = [1,2,3,4,5,6]
# the easy way
for element in list:
print element, ',',
print
# this is what I really want. is there some way better?
if (len(list) > 0):
print list[0],
for element in list[1:]:
print ',', element,
</code>
Thx,
Ernesto
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?
<code>
list = [1,2,3,4,5,6]
# the easy way
for element in list:
print element, ',',
# this is what I really want. is there some way better?
if (len(list) > 0):
print list[0],
for element in list[1:]:
print ',', element,
</code>
Thx,
Ernesto