Flatten a list

Write a program that prints every given list flattened. For example, [[[a]],b][[[a]], b] flattened is [a,b][a, b], and [[a,b],[c,d]][[a, b], [c, d]] flattened is [a,b,c,d][a, b, c, d].

Define and use a recursive function

flatten(t)

that flattens a list tt.

Hint

Using the @ast@ package, you can extract the list tt encoded in a string ss with @t = ast.literal_eval(s)@.

Input

The input consists of several lists.

Output

Print every given list flattened.

Problem information

Author: Gabriel Valiente

Generation: 2026-01-25T17:16:35.768Z

© Jutge.org, 2006–2026.
https://jutge.org