Computer Science Homework Help
this is a python programming
I Have Your answer to this problem in the”Millen. py” like !`Recall that & Python list can contain any type of element , even another list. As a result, we can have list of lists, licks of listsof lists , and so on . with ever- increasing levels of nesting . This problem intends to put a stop In that sort of nonsense .Complete the Flatten ! ! function , which takes a single list as its argument . The function examines its list argument and*RECURSIVELY’ generates (and returns ; a new single- level ( non – nested; list that contains every element from the originallist, in the same onder it appeared in that list . For example , the list 12. 14. 61 . $1 contains a list as one of its elements !Flatten ! ! will process this list and return the new single- level list 12. 4 6. $1. where the inner list has been eliminated!and its elements have replaced the original sublistThe possible recursive strategy resembles the following*. If the current list is an empty list . simply return an empty list ( This is your base case ). Otherwise !. If the first element of the current list is a list, return the result of flattening that list plus the result of flattening thereminder of the list . ( This is your first recursive case )*. Otherwise , return a list containing just the first element plus the result of flattening the remainder of the list . ( ThisIs your second recursive case )Hint : Python has a special function named is instance !’ that can be extremely helpful here. isinstance !’ lakestwo arguments . & value to examine , and the name of a Python type (in this case . List) . It reams True or Falsedepending on whether the first argument belongs In the specified type . For example , the function call is instance ( 12 .int ) returns True . while the function call & singtance ! ‘ 3 . 14 ‘, Float ; returns False.Function LullHeturn ValueFlatten ! ! ! !Flatten $ 1 21 1121Flatteni13 . 5 . 1 . 01 113 . 6 . 1 . 01Flatten ! ! 151 1 1Flatten 1 1 1 . 3 . 5 . 171 . 5 . 11 1 1[ 15111 . 3 . 5 . 7 . 5 . 111flatten ! ! !$1 . 32 . 36 . 55 , 193. 541 . 50 .15 . 32 , 36 . 55, 53 . 59 . 98 , BB ]leei’llFlatten ! ! ! !131 1 1 1 1131Flatten $ 165 , 152 . 411 . 17. 124. 351 . 931 .165 , 52 . 41 . 7, 14. 35, 93, 73, 33 . 5^ ^ ^` .`73 . 33 . 91. 14. 163, 24 . 1 127 , 381 . 178 .$3 , 24 , 27 , 89 , 78 , 75, 13, 31 , 84175 . 131 . 311 . 841 1 1