The Lazy Unpacker
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
A nightly job emits grouped metric readings as a list `nested` whose entries are either numbers or further lists, nested to arbitrary depth. Collapse it into a single flat list of every non-list value, preserving the left-to-right order in which they appear. An empty `nested`, or one holding only empty lists, comes back as an empty list.
Summary
Peel back every layer until only the values remain.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.