To write a two-dimensional array, initialize the outer list first You need to put the item in the outside list.
# Create a 5x5 list with all elements zero
Matrix = [[0]*5 for i in range(5)]
# Change the value by accessing the index
Matrix[0][0] = 1
Matrix[4][0] = 5
#Output
print Matrix[0][0] # prints 1
print Matrix[4][0] # prints 5
© 2024 OneMinuteCode. All rights reserved.