Python | Nth Column vertical string in Matrix
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
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course