joining strings question
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Feb 29 16:29:16 CET 2008
patrick.waldo at gmail.com a écrit :
> Hi all,
> I have some data with some categories, titles, subtitles, and a link
> to their pdf and I need to join the title and the subtitle for every
> file and divide them into their separate groups.
> So the data comes in like this:
> data = ['RULES', 'title','subtitle','pdf',
> What I'd like to see is this:
> [RULES', 'title subtitle','pdf', 'title1 subtitle1','pdf1'],
> ['NOTICES','title2 subtitle2','pdf','title3 subtitle3','pdf'], etc...
I don't know where your data come from, but the data structure is
obviously wrong. It should at least be a list of tuples, ie:
data = [
('title', 'subtitle', 'pdf'),
('title1', 'subtitle1', 'pdf1')
> I've racked my brain for a while about this and I can't seem to figure
> it out. Any ideas would be much appreciated.
If possible, fix the code generating the dataset. Any other solution
will be at best a dirty - and brittle - hack.
More information about the Python-list