Sometimes, while working with Python Matrix, we can have a problem in which we need to check if an element is present or not. This problem is simpler, but a variation to it can be to perform a check in particular column of Matrix. Let’s discuss a shorthand by which this task can be performed.
Method : Using
any() + list comprehension
This task can be performed using combination of above functions in which we imply list comprehension for iteration and support tasks and
any() can be used to check for any occurrence of the desired character.
The original list : [[1, 4, 5], [6, 7, 8], [8, 3, 0]] Does element exists in particular column : True
- Python | Search in Nth column in list of tuples
- Python | Max/Min value in Nth Column in Matrix
- Python | Get Kth Column of Matrix
- Python | Nth column Matrix Product
- Python - Summation of kth column in a matrix
- Python - Remove front column from Matrix
- Python | Nth Column vertical string in Matrix
- Python | Search elements in a Matrix
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Python Program for Anagram Substring Search (Or Search for all permutations)
- Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix
- Python | Column summation of tuples
- Python - Constant Multiplication to Nth Column
- Python | Convert Lists to column tuples
- Python - Get maximum of Nth column from tuple list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.