In the code from below, I wanted to insert some data in a matrix and I was surprised by IndexError. I can't understand why the error is here, it seems that everything is wright.
matrix=[[]]
n=int(input("number of lines and columns n= "))
for i in range(n):
for j in range(n):
x=int(input())
matrix[i].insert(j,x)
print(i,j)
EDIT:
I understand that my problem had nothing to do with what I thought initially. The mistake was that I wanted to insert x in a list that didn't exist in my matrix variable. The solution is just to append a new list in the first loop, and after that to add desired elements.