Concatenate string list to number list to form title - Logic

A forum for general discussion of the Python programming language.

Concatenate string list to number list to form title - Logic

Postby Ravi_exact » Mon Dec 16, 2013 5:23 pm

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.

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


Expected Result : ( list of strings )
Code: Select all
['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
Last edited by stranac on Mon Dec 16, 2013 5:42 pm, edited 1 time in total.
Reason: First post lock.
Ravi_exact
 
Posts: 1
Joined: Mon Dec 16, 2013 5:20 pm

Re: Concatenate string list to number list to form title - L

Postby stranac » Mon Dec 16, 2013 5:44 pm

Why do you want to do this without loops?
Loops seem like the right way to do this.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1209
Joined: Thu Feb 07, 2013 3:42 pm

Re: Concatenate string list to number list to form title - L

Postby ochichinyezaboombwa » Tue Dec 17, 2013 12:00 am

Will list comprehension work for you? (it has loops but only implicitly).
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: Concatenate string list to number list to form title - L

Postby micseydel » Tue Dec 17, 2013 2:27 am

You could use slicing and recursion. Or map() and slicing.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1436
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests

cron