1
Hello The code below gives the following error message:
Traceback (Most recent call last): File "C:/Users/Usuario/Documents/tests python/várias.py", line 12, in mult[i][j] = (i*j) Indexerror: list assignment index out of range
I ask you, who is out of range? i? j? What to analyze (I changed all ranges with all possible values) when you receive this message (I know it means that you are trying to access an element outside the established limits), because I don’t see what or who is outside. Objetivo:[[0,0,0],[0,1,2],[0,2,4]...[0,10,20]] Thank you very much.
mult =[[] for _ in range(10)]
for i in range(10):
for j in range(3):
mult[i][j] = (i*j)
print(mult)
i
who is out of the range. You have feathers a list containing 10 other empty lists. Try this wayprint([[i*j for j in range(3)] for i in range(10)])
– Augusto Vasques