How to pass 2D list (array) (matrix) to function in Python

1 Answer

0 votes
def print_matrix(a_matrix):
    for rows in a_matrix:
        for col in rows:
            print(col, end=" ")
        print()

matrix = [[11, 42, 53],
          [78, 50, 989]]


print_matrix(matrix)


'''
run:

11 42 53
78 50 989

'''

 



answered Apr 15, 2018 by avibootz

Related questions

1 answer 164 views
1 answer 231 views
1 answer 151 views
1 answer 152 views
1 answer 143 views
1 answer 134 views
1 answer 228 views
...