4 examples of 'check if element is in list python' in Python

Every line of 'check if element is in list python' 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
this disclaimer
20def in_list(value, arg):
21 return value in ( arg or [] )
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

6def list_has(list, x):
7 try:
8 list.index(x)
9 return True
10 except ValueError:
11 return False
40def _is_iterable(element):
41 return hasattr(element, '__iter__') and not isinstance(element, str)
180def has_element(lst, el):
181 for i in lst:
182 if i == el:
183 return True
184 return False

Related snippets