Question: Below are two attempts to write a function, make_list_of_lists, that creates a list of n lists of increasing ranges of integers. The first entry in
Below are two attempts to write a function, make_list_of_lists, that creates a list of n lists of increasing ranges of integers. The first entry in the returned list should be an empty list, the second a list of length one, ending with the number 1, and so on. For example, make_list_of_lists(3) should return [ [], [1], [1, 2] ]. However, both attempts are incorrect. Locate the error in each function and fix it so it produces the correct output.

Function 1 def make_list_of_lists(n): the-list = [ ] sublist [ while n>0: the_list.append (sublist) sublist.append (len (sublist) 1) return the list Function 2 def make_list_of_lists (n): the-list = [ ] sublist[ for i in range (n): the_list.extend (sublist) sublist = sublist.insert (len(sublist), ) return the list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
