+ 1
Do Someone know the reason ot the code stays wrong? The error happens because the matrix's index
3 Respuestas
+ 3
Basically the code is trying to assign values at a list location that it doesn't have yet. For the same reason something like the following won't work
a = []
a[0] = 1
To add new entries, we use the list.append method. One way to fix your code is this:
for line in range(0, lines):
matrix.append([]) # adds a new row
for column in range(0, columns):
matrix[line].append(rand(0, 100))
+ 2
You're welcome! :)
+ 1
Thank you so much ✌✌