How to unnest a nested list

Viewed 169011

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]
4 Answers
Related