-1
I created a function that takes as a parameter an Nxn matrix, and initially prints the top edge of the matrix, but I keep getting the error "Indexerror: list index out of range", and this prevents calling other functions.
def bordaSuperior(matriz): # Separa os números da borda superior
lin = 0
col = 0
for i in matriz: # Valores da Borda Superior
for j in matriz:
print(matriz[lin][col])
col += 1
Your logic is wrong... You only increment the variable
col
, that is, if you have a 3x3 matrix you will try to accessmatriz[0][0]
untilmatriz[0][8]
. And as you can see there is no such element in the lists..– fernandosavio