10 examples of 'python check if any element in list is in another list' in Python

Every line of 'python check if any element in list is in another list' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
6def list_has(list, x):
7 try:
8 list.index(x)
9 return True
10 except ValueError:
11 return False
402def DoesListContainsList(big, small):
403 for s in small:
404 if s not in big: return False
405 return True
20def in_list(value, arg):
21 return value in ( arg or [] )
65def any(items):
66 for item in items:
67 if item:
68 return True
69 return False
5def containsAny(seq, aset):
6 for c in seq:
7 if c in aset: return True
8 return False
120def _compare_lists(*args):
121 """
122 Compare two or more lists. Return True if all equals.
123 """
124
125 if not args:
126 return True
127 compared_item = set(args[0])
128 for item in args[1:]:
129 if compared_item != set(item):
130 return False
131 return True
340def __eq__(self, other):
341 if len(self) != len(other):
342 return False
343 for i in range(len(self)):
344 if self[i] != other[i]:
345 return False
346 return True
392def _check_remove_item(the_list, item):
393 """Helper function for merge_lists that implements checking wether an items
394 should be removed from the list and doing so if needed. Returns ``True`` if
395 the item has been removed and ``False`` otherwise."""
396 if not isinstance(item, basestring):
397 return False
398 if not item.startswith('~'):
399 return False
400 actual_item = item[1:]
401 if actual_item in the_list:
402 del the_list[the_list.index(actual_item)]
403 return True
101def __contains__(self, value):
102 return value in self._dict
7def is_unique_list(seq):
8 for i in seq:
9 if seq.count(i) != 1:
10 return False
11 return True

Related snippets