In this video course, you’ve learned how to flatten a list of lists in Python. You’ve used different tools and techniques to accomplish this task. First, you used a for
loop along with the .extend()
list method. Then you used other tools, such as list comprehensions and functions like functools.reduce()
, itertools.chain()
, and sum()
.
Then you ran a performance test to find out which of these tools offer faster solutions for flattening lists of lists. The test results indicate that your best options include using a loop and the .extend()
method or the augmented concatenation operator.
With all this knowledge, you’re now ready to start flattening nested data in Python.