"Opposite" of splitting?

Paul Rubin http
Sun Jun 5 19:14:47 EDT 2005


Jan Danielsson <jan.danielsson at gmail.com> writes:
> I have a list of integers:
> q = [ 1, 2, 4, 7, 9 ]
> which I would like to convert to a string:
> "1,2,4,7,9"

s = ','.join([str(n) for n in q])

Alternatively, just repr(q) gives you '[1, 2, 4, 7, 9]' (with the
brackets and spaces).



More information about the Python-list mailing list