def print_matrix(matrix):
 matrixT = [[] for x in range(len(matrix[0]))]
 for i in range(len(matrix)):
  for j in range(len(matrix[i])):
   matrixT[j].append(len(str(matrix[i][j])))
 ndigits = [max(x) for x in matrixT]
 for i in range(len(matrix)):
  print(' '.join((('%*s ' % (ndigits[j], matrix[i][j])) for j in range(len(matrix[i])))))

def print_matrix ( matrix ) : matrixT = [ [ ] for x in range ( len ( matrix [ 0 ] ) ) ] for i in range ( len ( matrix ) ) : for j in range ( len ( matrix [ i ] ) ) : matrixT [ j ] . append ( len ( str ( matrix [ i ] [ j ] ) ) ) ndigits = [ max ( x ) for x in matrixT ] for i in range ( len ( matrix ) ) : print ( ' ' . join ( ( ( '%*s ' % ( ndigits [ j ] , matrix [ i ] [ j ] ) ) for j in range ( len ( matrix [ i ] ) ) ) ) )
print_matrix print out a matrix .