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 fives(): size = int(input()) matrix = [] for i in range(size): matrix.append([]) for j in range(size): if j < size - 1: matrix[i].append(1) else: matrix[i].append(5) for i in range(size): print(*matrix[i]) fives()

Questions about programming?Chat with your personal AI assistant