← Questions

Flatten and rebuild nested Python containers

0
xAICodingLast asked Mar 2026

Given an arbitrarily nested mix of lists, tuples and dicts with integer leaves, produce a flat list of the integers in order. Then, given the original structure and a new flat list, rebuild a structure of the same shape filled with the new values.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding