Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #86234

Re: Concatenate list values

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'strings.': 0.09; '-tkc': 0.16; 'concatenate': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'iterable': 0.16; 'received:174.136': 0.16; 'subject:values': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'string,': 0.24; 'skip:" 30': 0.26; 'skip:" 20': 0.27; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'thus': 0.29; 'subject:list': 0.30; 'work.': 0.31; "can't": 0.35; 'except': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'should': 0.36; 'list': 0.37; 'received:10': 0.37; 'lists.': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'length': 0.61; 'first': 0.61
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-Sender-Id wwwh|x-authuser|tim@thechases.com
X-MC-Relay Neutral
X-MailChannels-SenderId wwwh|x-authuser|tim@thechases.com
X-MailChannels-Auth-Id wwwh
X-MC-Loop-Signature 1424707985747:1936141862
X-MC-Ingress-Time 1424707985747
Date Mon, 23 Feb 2015 10:14:34 -0600
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: Concatenate list values
In-Reply-To <12821378-62af-4954-8b61-aa0738c5ff5c@googlegroups.com>
References <12821378-62af-4954-8b61-aa0738c5ff5c@googlegroups.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AuthUser tim@thechases.com
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.19079.1424707997.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1424707997 news.xs4all.nl 2971 [2001:888:2000:d::a6]:47418
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:86234

Show key headers only | View raw


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




Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Concatenate list values loial <jldunn2000@gmail.com> - 2015-02-23 07:58 -0800
  Re: Concatenate list values John Gordon <gordon@panix.com> - 2015-02-23 16:07 +0000
  Re: Concatenate list values alister <alister.nospam.ware@ntlworld.com> - 2015-02-23 16:08 +0000
  Re: Concatenate list values Peter Otten <__peter__@web.de> - 2015-02-23 17:09 +0100
  Re: Concatenate list values Tim Chase <python.list@tim.thechases.com> - 2015-02-23 10:14 -0600
  Re: Concatenate list values Andrew Berg <aberg010@my.hennepintech.edu> - 2015-02-23 10:14 -0600
  Re: Concatenate list values Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-23 17:13 +0000
    Re: Concatenate list values wxjmfauth@gmail.com - 2015-02-24 02:30 -0800
  Re: Concatenate list values loial <jldunn2000@gmail.com> - 2015-02-24 00:37 -0800

csiph-web