Concatenate list values

Tim Chase python.list at tim.thechases.com
Mon Feb 23 11:14:34 EST 2015


On 2015-02-23 07:58, loial wrote:
> Is there a quick way to concatenate all the values in a list into a
> string, except the first value?
> 
> I want this to work with variable length lists.
> 
> All values in list will be strings.

Using

  "".join(my_list[1:])

should work.

If it is an arbitrary iterable instead of a list (and thus can't be
sliced), you can use

  "".join(itertools.islice(my_iter, 1, None))

-tkc








More information about the Python-list mailing list