Format list of list sub elements keeping structure.

Sayth Renshaw flebber.crue at gmail.com
Tue Jul 24 01:11:49 EDT 2018


On Tuesday, 24 July 2018 14:25:48 UTC+10, Rick Johnson  wrote:
> Sayth Renshaw wrote:
> 
> > elements = [['[{0}]'.format(element) for element in elements]for elements in data]
> 
> I would suggest you avoid list comprehensions until you master long-form loops.

My general issue is that I want to pick up all the elements in each sublist and operate on them to concatenate them together.

However, using for loops I get each list then each element of each list.
When in my head I want each list then all elements of each list.

Sayth


More information about the Python-list mailing list