Question: Q1: Flatten Write a function flatten that takes a (possibly deep) list and flattens it. For example: >>>1st [1, [[2], 3], 4, [5, 6]] >>>

 Q1: Flatten Write a function flatten that takes a (possibly deep)

Q1: Flatten Write a function flatten that takes a (possibly deep) list and "flattens" it. For example: >>>1st [1, [[2], 3], 4, [5, 6]] >>> flatten(1st) Hint: you can check if something is a list by using the built-in type function. For example, >>>type(3)list False >>>type([1, 2, 3])list True You have write your own flatten method. def flatten lst): """Returns a flattened version of lst. >>> flatten ([1, 2, 3]) >>> flatten([1, [2, 3], 4]) >>>flatten([[1, [2, 311, 4, [5, 6]]) [12 2, 3, 4, 5, 6 # YOUR CODE GOES HERE #

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!