No-one has given the usual answer:
def flat(l):
return [y for x in l for y in x]
There are dupes of this question floating around StackOverflow.
More Related Contents:
- Why is a list comprehension so much faster than appending to a list?
- sum each value in a list of tuples
- Skip elements on a condition based in a list comprehension in python
- Find a unique element in a list [closed]
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- List comprehension on a nested list?
- What do ellipsis […] mean in a list?
- if else in a list comprehension [duplicate]
- Transpose a matrix in Python [duplicate]
- Insert an element at a specific index in a list and return the updated list
- List on python appending always the same value [duplicate]
- List comprehension vs generator expression’s weird timeit results?
- List vs generator comprehension speed with join function [duplicate]
- 2D list has weird behavor when trying to modify a single value [duplicate]
- python filter list of dictionaries based on key value
- How to return a subset of a list that matches a condition [duplicate]
- Print LIST of unicode chars without escape characters
- How to remove multiple items from a list in just one statement?
- Write and read a list from file
- Comprehension on a nested iterables?
- remove None value from a list without removing the 0 value
- How can I use list comprehensions to process a nested list?
- How to apply a function to each sublist of a list in python?
- Duplicate elements in a list [duplicate]
- Converting List Comprehensions to For Loops in Python
- range(len(list)) or enumerate(list)? [duplicate]
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- How to sort list of lists according to length of sublists [duplicate]
- Converting string to tuple without splitting characters
- How does all() in python work on empty lists