5 examples of 'python check if value exists in list' in Python

Every line of 'python check if value exists in 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
20def in_list(value, arg):
21 return value in ( arg or [] )
31def _value_exists(self, value):
32 """
33 Checks if the value exists in the storage
34
35 @param value: value to be checked in storage
36 @type value: string
37
38 @return: result of select SQL query
39 @rtype: tuple
40 """
41 return run_sql("""SELECT seq_value FROM seqSTORE
42 WHERE seq_value=%s AND seq_name=%s""",
43 (value, self.seq_name))
5def _find_dict_in_list(list_of_dict, key, val):
6 """Given a list of dictionaries, return the first dictionary that has the
7 given key:value pair.
8 """
9 try:
10 for d in list_of_dict:
11 if (key, val) in d.items():
12 return d
13 except TypeError:
14 pass
1def contains_val(data, key, value):
2 """
3 check if certain key has certain value, return true if so and false otherwise
4 """
5 # try to get value variable from parser specific variables
6 value = _ttp_["parser_object"].vars.get(value, value)
7 if not value in data.get(key, ""):
8 return data, False
9 return data, None
14def check_if_one_item_has_property_v1(my_list, key):
15 """
16 Return true if at least one item has a
17 property.
18 """
19 list_position = 0
20 while list_position < len(my_list) and my_list[list_position] != key:
21 list_position += 1
22
23 if list_position < len(my_list):
24 # Found an item with the property
25 return True
26 else:
27 # There is no item with the property
28 return False

Related snippets