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 + join()**

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.

`# Python3 code to demonstrate working of ` `# Nth Column vertical string in Matrix ` `# Using join() + list comprehension ` ` ` `# initializing list ` `test_list ` `=` `[(` `'a'` `, ` `'g'` `, ` `'v'` `), (` `'e'` `, ` `'f'` `, ` `8` `), (` `'b'` `, ` `'g'` `, ` `0` `)] ` ` ` `# printing list ` `print` `(` `"The original list : "` `+` `str` `(test_list)) ` ` ` `# initializing Nth column ` `N ` `=` `1` ` ` `# Nth Column vertical string in Matrix ` `# Using join() + list comprehension ` `temp ` `=` `[sub[N] ` `for` `sub ` `in` `test_list] ` `res ` `=` `"".join(temp) ` ` ` `# Printing result ` `print` `(` `"Constructed vertical string : "` `+` `str` `(res)) ` |

*chevron_right*

*filter_none*

**Output :**

The original list : [('a', 'g', 'v'), ('e', 'f', 8), ('b', 'g', 0)] Constructed vertical string : gfg

## Recommended Posts:

- Python | Max/Min value in Nth Column in Matrix
- Python | Search in Nth Column of Matrix
- Python | Nth column Matrix Product
- Python - Vertical Concatenation in Matrix
- Python - Extract ith column values from jth column values
- Python | Search in Nth column in list of tuples
- Python - Get maximum of Nth column from tuple list
- Python - Get Nth column elements in Tuple Strings
- Python - Constant Multiplication to Nth Column
- Python - Remove Record if Nth Column is K
- Python | String List to Column Character Matrix
- Create a DataFrame from a Numpy array and specify the index column and column headers
- Get column index from column name of a given Pandas DataFrame
- Create a Pandas DataFrame from a Numpy array and specify the index column and column headers
- Python - Interconvert Horizontal and Vertical String
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Python | Get Kth Column of Matrix
- Python - Summation of kth column in a matrix
- Python - Remove front column from Matrix
- Python | Matrix Tuple pair Column product

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.