how to join array of integers?

timw.google tjandacw at yahoo.com
Mon Sep 17 18:14:10 CEST 2007


On Sep 17, 8:46 am, John Machin <sjmac... at lexicon.net> wrote:
> On Sep 17, 10:16 pm, "timw.google" <tjand... at yahoo.com> wrote:
>
>
>
>
>
> > On Sep 15, 8:36 am, Summercool <Summercooln... at gmail.com> 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?
>
> > Isn't the OP just looking for something like:
>
> > >>> foo=[1,2,3]
> > >>> bar=[4,5,6]
> > >>> foo+bar
> > [1, 2, 3, 4, 5, 6]
>
> No. Read what he wrote. He has a SINGLE list whose elements are (e.g.)
> integers [1, 2, 3], *NOT* two lists. He wants to create a STRING
> "1,2,3", not a list.- Hide quoted text -
>
> - Show quoted text -

You're right. I read it wrong. Sorry.




More information about the Python-list mailing list