python print 2d list code example
Example 1: how to transpose a 2d list in python
import numpy as np
def func(my_matrix):
# Making np array of the list
my_matrix = np.array(my_matrix)
# Find the transpose to get image vector in column
my_matrix = my_matrix.transpose()
return my_matrix
Example 2: 2d array python initialize
>>> b = [['a']*3]*3
>>> b
[['a', 'a', 'a'], ['a', 'a', 'a'], ['a', 'a', 'a']]
>>> b[1][1]
'a'
>>> b[1][1] = 'b'
>>> b
[['a', 'b', 'a'], ['a', 'b', 'a'], ['a', 'b', 'a']]