Given a list of lists, the task is to determine whether the given element exists in any sublist or not. Given below are a few methods to solve the given task.
Method #1: Using any()
any() method return true whenever a particular element is present in a given iterator.
Method #2: Using operator in
The ‘in’ operator is used to check if a value exists in a sequence or not. Evaluates to true if it finds a variable in the specified sequence and false otherwise.
Method #3: Using
Make an iterator that returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted.
- Python | Check if a list exists in given list of lists
- Python | Ways to check if element exists in list
- Python | Merge two list of lists according to first element
- Python | Remove given element from list of lists
- Python | Check if two lists have any element in common
- Python | Check if two lists have at-least one element common
- Python - Check if string starts with any element in list
- Python | Check if any element occurs n times in given list
- Python | Check if any element in list satisfies a condition
- Python | Program to count number of lists in a list of lists
- Python | Check whether given key already exists in a dictionary
- Python | Merge List with common elements in a List of Lists
- Python | Sorting list of lists with similar list elements
- Python | Check if tuple exists as dictionary key
- Python: Check if a File or Directory Exists
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.