Given a list of lists, the task is to check if a list exists in given list of lists.
Input : lst = [[1, 1, 1, 2], [2, 3, 4], [1, 2, 3], [4, 5, 6]] list_search = [4, 5, 6] Output: True Input : lst = [[5, 6, 7], [12, 54, 9], [1, 2, 3]] list_search = [4, 12, 54] Output: False
Let’s discuss certain ways in which this task is performed.
Method #1: Using Counter
The most concise and readable way to find whether a list exists in list of lists is using Counter.
Method #2: Using in
Method #3: Using
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 element exists in list of lists
- Python | Program to count number of lists in a list of lists
- Python | Zipping two lists of lists
- Python - Convert Lists into Similar key value lists
- Check if element exists in list in Python
- Python | Check whether given key already exists in a dictionary
- 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 | Get positive elements from given list of lists
- Python | Remove given element from list of lists
- Python | Find frequency of given character at every position in list of lists
- Python | Check if tuple exists as dictionary key
- Python - Check if a file or directory exists
- 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.