''' This code use python array syntax ''' # declare a 2D array array = [ [0 for col in range(3) ] for row in range(3)] print array # update array array[1][1]=5 print array
Output:
[[0, 0, 0], [0, 0, 0], [0, 0, 0]] [[0, 0, 0], [0, 5, 0], [0, 0, 0]]
''' This code use python array syntax ''' # declare a 2D array array = [ [0 for col in range(3) ] for row in range(3)] print array # update array array[1][1]=5 print array
[[0, 0, 0], [0, 0, 0], [0, 0, 0]] [[0, 0, 0], [0, 5, 0], [0, 0, 0]]
0 comments:
Post a Comment