Add Matrices

    0

    0

    Aakanksha Priya

    X = [[4,3,9],
        [1,2,0],
        [5,1,4]]
    Y = [[2,7,0],
        [1,2,4],
        [4,5,1]]
    result = [[0,0,0],
            [0,0,0],
            [0,0,0]]
    # iterate through rows
    for i in range(len(X)):  
    # iterate through columns
        for j in range(len(X[0])):
            result[i][j] = X[i][j] + Y[i][j]
    for r in result:
        print(r)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.