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


Groups > comp.lang.python > #62084

Re: Concatenate string list to number list to form title - Logic needed.

References <2333bfb4-cd72-4ed0-9b28-d8dbe26b5be2@googlegroups.com> <mailman.4224.1387214986.18130.python-list@python.org> <6112663707411483025@unknownmsgid>
Date 2013-12-17 04:51 +1100
Subject Re: Concatenate string list to number list to form title - Logic needed.
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4226.1387216286.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Dec 17, 2013 at 4:41 AM, Ravi Prabakaran <ravi.itm@gmail.com> wrote:
>> Hi Chris,
>
> Thanks for reply.   If you have any good idea with loop, please post.  But
> i'm looking same without loop because python has slicing,concatenating and
> other straight forward feature. I guess it can be done without loop.  My
> client does not prefer loops and expects simple and neat code to improve
> performance. We are dealing with billion data.

I'm going to hope that it was in error that you sent this off-list, or
at least that you won't mind my replying on-list. Here's one way to do
it:

t = ['Start','End']
a = [[1,2,3,4],
     [5,6,7,8]]
result = []
for cur in a:
     result.append("%s - %d"%(t[0],cur[2]))
     result.append("%s - %d"%(t[1],cur[3]))

ChrisA

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


Thread

Concatenate string list to number list to form title - Logic needed. Ravi Prabakaran <ravi.itm@gmail.com> - 2013-12-16 09:16 -0800
  Re: Concatenate string list to number list to form title - Logic needed. Chris Angelico <rosuav@gmail.com> - 2013-12-17 04:29 +1100
    Re: Concatenate string list to number list to form title - Logic needed. Chris Angelico <rosuav@gmail.com> - 2013-12-17 04:51 +1100
    Re: Concatenate string list to number list to form title - Logic needed. Chris Angelico <rosuav@gmail.com> - 2013-12-17 04:52 +1100
  Re: Concatenate string list to number list to form title - Logic needed. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-16 17:43 +0000
  Re: Concatenate string list to number list to form title - Logic needed. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-12-16 20:13 +0200
    Re: Concatenate string list to number list to form title - Logic needed. Peter Otten <__peter__@web.de> - 2013-12-16 19:37 +0100
  Re: Concatenate string list to number list to form title - Logic needed. John Gordon <gordon@panix.com> - 2013-12-16 18:50 +0000
  Re: Concatenate string list to number list to form title - Logic needed. Terry Reedy <tjreedy@udel.edu> - 2013-12-16 15:23 -0500

csiph-web