generate functionMon, 20 Mar 2023

A natural number N is entered (that is, a positive integer). Required to create a two-dimensional (nested) list of size N x N elements, consisting of all ones, and then, write fives in the last column. Display this list on the screen as a table of numbers, as shown in the example below. P.S. Be careful there should be no spaces at the end of the lines!

def add_col_num(n): my_list = [] for i in range(n): my_list.append([1] * n) for i in range(n): for j in range(n): if j == n-1: my_list[i][j] = 5 for i in range(n): print(*my_list[i])

Questions about programming?Chat with your personal AI assistant