Possible Duplicate:
Making a flat list out of list of lists in Python
I am trying to find an easy way to turn a multi dimensional (nested) python list into a single list, that contains all the elements of sub lists.
For example:
A = [[1,2,3,4,5]]
turns to
A = [1,2,3,4,5]
or
A = [[1,2], [3,4]]
turns to
A = [1,2,3,4]
[item for sublist in l for item in sublist]. This is a duplicate of a number of other questions. See, for example, stackoverflow.com/q/952914/623518, stackoverflow.com/q/406121/623518 and stackoverflow.com/q/457215/623518. - Chris