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 | Get Kth Column of Matrix
- Python | Max/Min value in Nth Column in Matrix
- Python | Nth column Matrix Product
- Python - Summation of kth column in a matrix
- Python | Nth Column vertical string in Matrix
- Python - Remove front column from Matrix
- Python - Reverse sort Matrix Row by Kth Column
- Python | Matrix Tuple pair Column product
- Python - Uneven Sized Matrix Column Minimum
- Python | Uneven Sized Matrix Column product
- Python | String List to Column Character Matrix
- Python | Search elements in a Matrix
- Python program to search for the minimum element occurring consecutively n times 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 - Maximum of each Column
- Python - Constant Multiplication to Nth Column
- Python | Column Mean in 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.