Question: 2. Flattening a list Write a function that takes a list as input and returns a flattened list. Flattening removes the nesting in a list

 2. Flattening a list Write a function that takes a list

2. Flattening a list Write a function that takes a list as input and returns a flattened list. Flattening removes the nesting in a list as follows inlist ['reptile', ['cat', 'dog', 'horse'], 3.14, [1, 3, 5, 7], final'] flatlist- ['reptile', "cat, 'dog', 'horse', 3.14, 1, 3, 5, 7, 'final] Assume the input list has a nesting level of no more than 2 and list elements can be string, float, int or a list. (Hint: you can use the statement type(item)type(I) to check if a list item v is a list or not)

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!