“Lista 2d en Python” Código de respuesta

Python inicializa una matriz 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

Cómo ingresar una matriz 2-D en Python

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
Clean Chamois

Lista 2d en Python


ar = [[0 for j in range(m)] for i in range(n)]

Dull Dunlin

Crea una matriz 2D en Python

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)
McBurd

Python Print 2D Matray como mesa

for row in A:
    for val in row:
        print '{:4}'.format(val),
    print
just-saved-you-a-stackoverflow-visit

Python Declare 2D List

length, breadth = x, y
matrix = [[-1 for j in range(breadth)] for i in range(length)]
# every element is -1
Famous Finch

Respuestas similares a “Lista 2d en Python”

Preguntas similares a “Lista 2d en Python”

Más respuestas relacionadas con “Lista 2d en Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código