Stack Exchange
Stack Overflow
Questions
Tags
Users
About
Stack Overflow
Public
Questions
Tags
Users
About
How to flatten a list in Python
Asked
Jul 20 '15 at 02:01
Active
Jul 20 '15 at 02:04
Viewed
40 times
0
For example
list1=[[2,1],[3,4],[3,5]]
and I want a function to let it become
list1=[2,1,3,4,3,5]
python
python-3.x
edited Jul 20 '15 at 02:04
jpw
44,361
6
66
86
asked Jul 20 '15 at 02:01
Maggie Mak
111
see answer at http://stackoverflow.com/questions/406121/flattening-a-shallow-list-in-python
–
Jul 20 '15 at 02:03
`[item for sublist in list1 for item in sublist]`
–
jpw
Jul 20 '15 at 02:05
0 Answers
0