Python zainicjuj tablicę 2D
x = [[foo for i in range(10)] for j in range(10)]
# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)
Unusual Unicorn
x = [[foo for i in range(10)] for j in range(10)]
# x is now a 10x10 array of 'foo' (which can depend on i and j if you want)
matrix = [input().split() for i in range(no_of_rows)] # if only row is given and the number of coloumn has to be decide by user
matrix= [[input() for j in range(no_of_cols)] for i in range(no_of_rows)] # if both row and coloumn has been taken as input from user
ar = [[0 for j in range(m)] for i in range(n)]
def build_matrix(rows, cols):
matrix = []
for r in range(0, rows):
matrix.append([0 for c in range(0, cols)])
return matrix
if __name__ == '__main__':
build_matrix(6, 10)
for row in A:
for val in row:
print '{:4}'.format(val),
print
length, breadth = x, y
matrix = [[-1 for j in range(breadth)] for i in range(length)]
# every element is -1