Write a program that prints every given list flattened. For example, [[[a]], b] flattened is [a, b], and [[a, b], [c, d]] flattened is [a, b, c, d].
Define and use a recursive function
that flattens a list t.
Hint
Using the ast package, you can extract the list t encoded in a string s with t = ast.literal_eval(s).
Input
The input consists of several lists.
Output
Print every given list flattened.
Input
[] ['a'] [['a']] [[['a']]] ['a', 'b'] ['a', []] [[], 'a'] [['a'], 'b'] ['a', ['b']] [[['a']], 'b'] ['a', [['b']]] [['a', 'b'], ['c', 'd']]
Output
[] ['a'] ['a'] ['a'] ['a', 'b'] ['a'] ['a'] ['a', 'b'] ['a', 'b'] ['a', 'b'] ['a', 'b'] ['a', 'b', 'c', 'd']