Puzzle 14 - Recursive List Unpacking (with duplicates)

SAS
0
Flatten a Nested List Recursively in Python (Preserve Duplicates)

You’ve been given a jumbled guest list where names are stored in a nested structure of lists within lists. Some guests appear more than once — that’s okay. Your goal is to recursively unpack this structure into a flat list, keeping all duplicates and preserving the original order. This recursive solution should work with any level of nesting.


Input & Expected Output

Input List


Guests = ["John Doe","Jane Doe",["Emily Doe","John Doe","Michael Smith"],["sarah Johnson",["Michael Smith","David Brown","Alice Green"],"Bob White","Alice Green"]]

Try solving the question yourself! If you need help, click below to reveal the solution.





Post a Comment

0Comments

Post a Comment (0)