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

Chris Angelico rosuav at gmail.com
Mon Dec 16 18:51:21 CET 2013


On Tue, Dec 17, 2013 at 4:41 AM, Ravi Prabakaran <ravi.itm at 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



More information about the Python-list mailing list