Printing list/tuple elements on separate lines

Daniel Fetchinson fetchinson at googlemail.com
Fri Jun 5 06:44:07 CEST 2009


>> I have a large list of strings that I am unpacking
>> and splitting, and I want each one to be on a new line.
>>
>> An example:
>>
>> recs =
>> 'asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf'
>> [(rec.split('f')) for rec in recs]
>>
>> output:
>>
>> [['asd', 'asd', 'asd', 'asd', 'asd', ''], ['asd', 'asd', 'asd', 'asd',
>> 'asd', ''], ['asd', 'asd', 'asd', 'asd', 'asd', '']]
>>
>> desired output:
>>
>> [['asd', 'asd', 'asd', 'asd', 'asd', '']
>> ['asd', 'asd', 'asd', 'asd', 'asd', '']
>> ['asd', 'asd', 'asd', 'asd', 'asd', '']]

By slightly modifying your requirements this might be good too:

print '\n'.join( [ 'aaaaaa', 'bbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee' ] )


Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown



More information about the Python-list mailing list