table[1][2] would give the value in the second row, third column (since indices start at 0).

More specifically, what you're specifying is a list of lists, so table[1] would resolve to ['E','F','G','H'] (the second item in the overall list), and then taking the third element of that with [2] would give you 'G'.

Answer from Amber on Stack Overflow
Discussions

Print row in python - Stack Overflow
This is because the first index ... elements from that row. ... for the same reason. Since it's a square matrix, it'll work out either way, but that's just luck. Actually, it'd be best to just do this instead for simplicity: ... On each iteration of the loop, enumerate() yields ... More on stackoverflow.com
🌐 stackoverflow.com
How to print a matrix using Python - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Displaying python 2d list without commas, brackets, etc. and newline after every row (6 answers) Closed 9 years ago. I am trying to create a matrix and then print it using python with the following ... More on stackoverflow.com
🌐 stackoverflow.com
Print the row and column numbers of a matrix-python - Stack Overflow
I am trying to print the row number and column number of a matrix where the value is 1. For example: A=[0 1 0] [1 0 1] [1 0 0] I want the output to be displayed as:(row number followed by the More on stackoverflow.com
🌐 stackoverflow.com
python - Print the elements of the matrix with each row in a new line and elements of each row are separated by a space - Stack Overflow
You are provided with the number of rows (R) and columns (C). Your task is to generate the matrix having R rows and C columns such that all the numbers are in increasing order starting from 1 in ro... More on stackoverflow.com
🌐 stackoverflow.com
August 19, 2019
🌐
Delft Stack
delftstack.com › home › howto › python › print matrix python
How to Print Matrix in Python | Delft Stack
February 2, 2024 - import numpy as np a = np.array([[1, 2, 3], [3, 4, 5], [7, 8, 9]]) s = [[str(e) for e in row] for row in a] lens = [max(map(len, col)) for col in zip(*s)] fmt = "\t".join("{{:{}}}".format(x) for x in lens) table = [fmt.format(*row) for row in s] print("\n".join(table)) Output: 1 2 3 3 4 5 7 8 9 · Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe · Author: Manav Narula · Manav is a IT Professional who has a lot of experience as a core developer in many live projects. He is an avid learner who enjoys learning new things and sharing his findings whenever possible. LinkedIn · Adjacency Matrix in Python ·
🌐
Java2Blog
java2blog.com › home › python › how to print a matrix in python
How to Print a Matrix in Python [3 Ways] - Java2Blog
December 6, 2023 - NumPy is a popular library for numerical computations in Python. It provides a straightforward way to create and print matrices. ... np.array(matrix): This converts the list matrix into a NumPy array, which has its own print functionality that formats matrices neatly. print(np_matrix): NumPy arrays are printed in a clean and readable format by default. ... To compare the performance of the different matrix printing methods, we can use Python’s timeit module.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-matrix
Python - Matrix - GeeksforGeeks
July 23, 2025 - In this tutorial, we’ll explore different ways to create and work with matrices in Python, including using the NumPy library for matrix operations. ... A Matrix is fundamentally a 2D list therefore we can create a Matrix by creating a 2D list (list of lists). ... In this example we are going to take user inputs for rows and columns for the matrix and then print the complete matrix.
🌐
Derludditus
derludditus.github.io › ClaudePython › how-to-print-matrix-in-python.html
How to print a matrix in Python
When you print a list of lists with print(), Python shows the exact nested structure. NumPy arrays display in a more readable matrix format that reflects their underlying grid-like organization. This matters when working with large datasets where both visual clarity and computational speed count. Yes, you can extract specific rows and columns from a matrix using array indexing.
🌐
YouTube
youtube.com › watch
Python | Constructing and Printing a Matrix [warning: now-unrecommended function] - YouTube
This python tutorial teaches you how to construct and print a matrix in the *now-unrecommended* way (i.e. with numPy’s ‘matrix’ function). Apparently we shou...
Published: December 26, 2023
Find elsewhere
🌐
Replit
replit.com › home › discover › how to print a matrix in python
How to print a matrix in Python | Replit
April 14, 2026 - Discover multiple ways to print a matrix in Python. This guide covers tips, real-world uses, and how to debug common errors.
🌐
TutorialsPoint
tutorialspoint.com › python-print-rows-from-the-matrix-that-have-same-element-at-a-given-index
Python - Print rows from the matrix that have same element at a given index
September 4, 2021 - my_list = [[7745, 6755, 87, 978], [727, 927, 845], [192, 997, 49], [98, 74, 27]] print("The list is :") print(my_list) my_key = 1 print("The key is ") print(my_key) my_result = [element for element in my_list if all(str(i)[my_key] == str(element[0])[my_key] for i in element)] print("The result is :") print(my_result) The list is : [[7745, 6755, 87, 978], [727, 927, 845], [192, 997, 49], [98, 74, 27]] The key is 1 The result is : [[7745, 6755, 87, 978], [192, 997, 49]] A list of list is defined and is displayed on the console. The value for key is defined and displayed on the console. A list comprehension is used to iterate over the list, and the ‘all’ operator is used to check if a specific element at an index is equal to the key.
🌐
Sololearn
sololearn.com › en › Discuss › 1482839 › to-print-matrix-using-python
To print matrix using python
September 2, 2018 - Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-that-prints-rows-from-the-matrix-that-have-same-element-at-a-given-index
Python Program that prints rows from the matrix that have same element at a given index - GeeksforGeeks
July 23, 2025 - # initialize test_list test_list = [[3345, 6355, 83, 938], [323, 923, 845], [192, 993, 49], [98, 34, 23]] # printing original list print("The original list is : " + str(test_list)) # initialize K K = 1 # initialize an empty list for the result result = [] # loop through each row in the test_list for row in test_list: # initialize a flag to keep track of whether all elements in the row match match = True # loop through each element in the row for i in row: # compare the Kth digit of the current element with the Kth digit of the first element in the row if str(i)[K] != str(row[0])[K]: # if they
🌐
Medium
medium.com › the-python-diary › matrix-in-python-part1-fd125e2a77
Matrix in Python-Part1. In this story and next few parts we see… | by leangaurav | Industrial Python | Medium
October 5, 2019 - For rows get len() of entire matrix M since number of rows is number of lists in outer list. For columns check length of inner list. To access one complete row say second row (i.e. index 1), do like this.
🌐
Stack Overflow
stackoverflow.com › questions › 26689829 › print-the-row-and-column-numbers-of-a-matrix-python › 26689879
Print the row and column numbers of a matrix-python - Stack Overflow
G={i: [j for j, y in enumerate(row) if y] for i, row in enumerate(A)} print (G) ... Could you clarify what the problem is? Just printing out a dictionary is never going to give the output you want - you will have to do some formatting.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-retrieve-an-entire-row-or-column-of-an-array-in-python
How to Retrieve an Entire Row or Column of an Array in Python? - GeeksforGeeks
July 23, 2025 - Explanation: a[1] retrieves the second row and a[:, 2] extracts the third column by selecting all rows at column index 2.
🌐
Reddit
reddit.com › r/learnpython › how could i properly display array/ matrix in numpy?
r/learnpython on Reddit: How could I properly display array/ matrix in numpy?
March 16, 2025 -

Hello everyone,

I'm quite new to numpy and am learning matrix calculations using numpy arrays. Yet I'm having difficulties mentally how to read arrays as matrices, when printing them out they aren't visually similar in built to matrices.

# matrixbewerkingen 
a = np.array([[1, 2], [4, 5],[6,7]])
b = np.array([[5, 6], [7, 8]]) 
print(f"{a} and {b} multiplied becomes {a @ b} ")


[[1 2]
 [4 5]
 [6 7]] and [[5 6]
 [7 8]] multiplied becomes [[19 22]
 [55 64]
 [79 92]] 

is there a way to get them into a mentally more appealing display next to eachother? How do you work with matrices for the best visual support.

Thanks in advance python community!

🌐
GeeksforGeeks
geeksforgeeks.org › python-program-that-prints-the-rows-of-a-given-length-from-a-matrix
Python Program that prints the rows of a given length from a matrix - GeeksforGeeks
April 28, 2023 - we can use the map() function along with a lambda function to create a new list containing only the sublists that have length K. ... The original list is : [[3, 4, 5, 6], [1, 4, 6], [2], [2, 3, 4, 5, 6], [7, 3, 1]] The filtered rows : [[1, 4, ...