Sometimes, while working with Python Matrix, we can have a problem in which we need to access the Matrix in vertical form and extract strings from same, that too as a string, not merely as a list of characters. This task has it’s application in gaming in which we need to extract string during crosswords. Let’s discuss a way in which this task can be performed.
Method : Using list comprehension +
We achieve the task in this method in 2 steps. In 1st step the Nth column elements are extracted using list comprehension. In 2nd step, these elements are joined together to perform the characters to string conversion.
The original list : [('a', 'g', 'v'), ('e', 'f', 8), ('b', 'g', 0)] Constructed vertical string : gfg
- Python | Get Kth Column of Matrix
- Python | Max/Min value in Nth Column in Matrix
- Python | Search in Nth Column of Matrix
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix
- Convert the column type from string to datetime format in Pandas dataframe
- Python | Column summation of tuples
- Python | Search in Nth column in list of tuples
- Python | Convert Lists to column tuples
- Python | Summation of Kth Column of Tuple List
- Python | Column wise sum of nested list
- Python | Column deletion from list of lists
- Limited rows selection with given column in Pandas | Python
- Python | Find most common element in each column in a 2D list
- Python | Column summation in uneven sized lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.