The Lazy Stream
A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L5
Problem
Given a list that may contain some inner lists (one level of nesting), return a flat list where inner lists are expanded element-by-element in place. Strings count as leaves even though iterable. Do not recurse into deeper levels.
Summary
Yield values one at a time from a potentially infinite source.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.