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!

N=5 def create_list(a): list_of_lists = [] for i in range(a): inner_list = [] for j in range(a): if j == N-1: inner_list.append(5) else: inner_list.append(1) list_of_lists.append(inner_list) return list_of_lists create_list(N)

Questions about programming?Chat with your personal AI assistant