Understanding Nested List Comprehensions in Python

Chad Mowbray
4 min readDec 14, 2020

Flatten multidimensional arrays using Python’s list comprehensions

If you feel like you understand this,

[x for x in range(10)]

but are at a loss when you see this,

[y for x in range(10) for y in range(x)]

--

--

Chad Mowbray

I study Arabic literature and software engineering.