how to join array of integers?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Sat Sep 15 08:42:49 EDT 2007
On Sat, 15 Sep 2007 12:36:02 +0000, Summercool wrote:
> i think in Ruby, if you have an array (or list) of integers
>
> foo = [1, 2, 3]
>
> you can use foo.join(",") to join them into a string "1,2,3"
>
> in Python... is the method to use ",".join() ? but then it must take
> a list of strings... not integers...
>
> any fast method?
Convert them to strings before joining:
In [145]: foo = [1, 2, 3]
In [146]: ','.join(map(str, foo))
Out[146]: '1,2,3'
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list