We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 84. Flatten lists recursively (Droste Bite)

18 out of 18 users completed this Bite ...
Will you be Pythonista #19 to crack this Bite?
Average Bite difficulty 1-10 rating: 4.0
» Up for a challenge? 💪

Complete flatten that takes a list of lists (which can have lists ad infinitum) and flatten them into a one dimensional list.

So this input:

[1, [2, 3], [4, 5, [6, 7, [8, 9, 10]]]]
... should generate this output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Make sure you support both lists and tuples. You probably want to use recursion here ... have fun!

Github login button