Loading...
Loading...
Loading...
A list may contain integers and other lists, nested to any depth. Read it as JSON and print all integers in order, separated by spaces. Use recursion.
Example
Input
[1, [2, [3, 4]], 5]
Output
1 2 3 4 5
Four levels of lists.
Try the problem first. Open one hint at a time.
Read the line with json.loads.
For each item: if it is a list, flatten it, otherwise keep it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor