Bokep
- Viewed 178k times80edited Feb 3, 2017 at 17:12
You could solve this many ways. One that is pretty simple to understand is to just use a loop.
def comp(list1, list2):for val in list1:if val in list2:return Truereturn FalseA more compact way you can do it is to use map and reduce:
reduce(lambda v1,v2: v1 or v2, map(lambda v: v in list2, list1))Even better, the reduce can be replaced with any:
any(map(lambda v: v in list2, list1))You could also use sets:
len(set(list1).intersection(list2)) > 0Content Under CC-BY-SA license python - Checking if any elements in one list are in another
python - Find a value in a list - Stack Overflow
Python | Check if a list is contained in another list
- Question & Answer
Python Check if the List Contains Elements of another List
Find elements in one List that are not in the other …
WEBApr 9, 2024 · A step-by-step guide on how to find elements in one list that are not in the other using Python.
5 Best Ways to Check if a List is Contained in Another List in Python
Check Python List Contains Elements of Another List
WEBJul 15, 2024 · We can use the collections.Counter() class to check if a Python list contains all elements of another list by comparing the two counter objects. If the two counter objects are equal, then the first list …
Python – Check List Contains All Elements Of Another …
WEBIn Python, you can use a combination of the built-in all() function, list comprehension, and the membership operator to check if a list contains all elements of another list. Use the following steps to check if all elements …
Check if element exists in list in Python - GeeksforGeeks
Check if multiple Values are in a List in Python | bobbyhadz
Write a Python Program to Check Whether a List Contains a Sublist
Python Find in List – How to Find the Index of an Item or Element …
Python list contains: How to check if an item exists in list?
Finding Items in a Python List - Udacity
Find Duplicates in List Python (fastest 7 ways) - Tutorials Tonight
python - How to check if all items in a list are there in another list ...
5 Best Ways to Find Indices of List Elements in Another List in …
python - Find elements in one list that are not in the other - Stack ...
Python | Find missing and additional values in two lists
How to Get the First Match From a Python List or Iterable
How can I compare two lists in python and return matches
python - If statement to check if an array is not in another array ...
Related searches for python find values in another list