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.
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.
- Python | Check if a list exists in given list of lists
- Python | Program to count number of lists in a list of lists
- Check if element exists in list in Python
- Python | Zipping two lists of lists
- Python - Convert Lists into Similar key value lists
- Python | Remove given element from list of lists
- Python | Merge two list of lists according to first element
- Python | Maximum sum of elements of list in a list of lists
- Python | Ways to sum list of lists and return sum list
- Python | Convert list into list of lists
- Python | Sorting list of lists with similar list elements
- Python | Merge List with common elements in a List of Lists
- Python | Convert List of lists to list of Strings
- Python - Convert Key-Value list Dictionary to List of Lists
- Python - Convert List of Dictionaries to List of Lists
- Python | Check if two lists have at-least one element common
- Python | Check if two lists have any element in common
- Python | Concatenate two lists element-wise
- Python - Diagonal element addition among lists
- Creating a sorted merged list of two unsorted lists in Python
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.