Write a function make_lower_triangular_matrix(m) that returns an m x m matrix as a
list of lists where row i (counting from 0) starts with the numbers 1, 2, ..., i + 1
and is padded with zeros. For m = 0 return the empty list. Use nested comprehensions
rather than explicit loops.
Example
make_lower_triangular_matrix(5)
-> [[1, 0, 0, 0, 0],
[1, 2, 0, 0, 0],
[1, 2, 3, 0, 0],
[1, 2, 3, 4, 0],
[1, 2, 3, 4, 5]]
Implement this function:
def make_lower_triangular_matrix(m: int) -> list:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: m.
Input
5
Output
[[1, 0, 0, 0, 0], [1, 2, 0, 0, 0], [1, 2, 3, 0, 0], [1, 2, 3, 4, 0], [1, 2, 3, 4, 5]]