On 16/12/2013 17:16, Ravi Prabakaran wrote:
Hi,
I'm completely new to python. I just need simple logic to get output without 
any loops.
I have list of string and list of list of numbers.
Each string should be concatenated with every third and fourth values to 
generate proper titles in list of strings.

t = ['Start','End']
a = [[1,2,3,4],
      [5,6,7,8]]

Expected Result : ( list of strings )

['Start - 3 , End - 4',
  'Start - 7 , End - 8']

Note : First 2 values from each list should be ignored.

Could anyone please guide me with best solution without loops ?

Thanks
Ravi


I've no idea what your definition of "best" is but this works.

strings = ['{} - {} , {} - {}'.format(t[0], b[-2], t[1], b[-1]) for b in a]

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to