5 Ways To Flatten A List In Python

There are many ways to flatten a list in Python, but in this article, I’m going to mention my top five favorites.

Let’s get started.

Way 1: Loop over individual lists and use append to construct a single list

lst = [[1,2], [3,4,5]]full_list = []

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store