Write a function, triangle, which takes a number and produces a list, each element of which is

Question:

Write a function, triangle, which takes a number and produces a list, each element of which is a list of symbols.
When triangle is called with a nonnegative integer, n, it returns a list containing n number of lists. The first inner list has n elements, the second inner list has n−1 element, and so on until you reach the top with only one element list, which forms the shape of a triangle. Each of the inner lists contain only the numbers 0 and 1 and they alternate across lists. The result always has 0 as the first element of the first inner list, if any.
In the following examples, we have formatted the output to show the result more clearly, but your output will not look the same; it is sufficient to just get the outputs that are equal to those shown. Spaces in the lists are just for display purposes here; you are not required to print them:image

image

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: