How to check multiple variables against a value in Python? Last Updated : 19 May, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Given some variables, the task is to write a Python program to check multiple variables against a value. There are three possible known ways to achieve this in Python: Method #1: Using or operator This is pretty simple and straightforward. The following code snippets illustrate this method. Example 1: Python3 # assigning variables a = 100 b = 0 c = -1 # checking multiple variables against a value if a == -1 or b == 100 or c == -1: print('Value Found!') else: print('Not Found!') Output: Value Found! Method #2: Using in keyword It is usually used to search through a sequence but can very well replace the code above. Python3 # assigning variables a = 100 b = 0 c = -1 # checking multiple variables against a value if a in [100, 0, -1]: print('Value Found!') else: print('Not Found!') Output: Value Found! You can use it for inverse statements also: Example 2: Python3 # assigning variables a = 90 # checking multiple variables against a value if a not in [0, -1, 100]: print('Value Found!') else: print('Not Found!') Output: Value Found! Method #2: Using == operator This approach is only applicable to multiple variables when checked with a single value. Example 1: Python3 # assigning variables a = 9 b = 9 c = 9 # checking multiple variables against a value if a == b == c == 9: print('Value Found!') else: print('Not Found!') Output: Value Found! Comment More infoAdvertise with us Next Article How to parse boolean values with `argparse` in Python D dikshapatro Follow Improve Article Tags : Python python-basics Practice Tags : python Similar Reads How to check if a Python variable exists? Checking if a Python variable exists means determining whether a variable has been defined or is available in the current scope. For example, if you try to access a variable that hasn't been assigned a value, Python will raise a NameError. Letâs explore different methods to efficiently check if a va 3 min read How to parse boolean values with `argparse` in Python Command-line arguments are a powerful feature of many programming languages, including Python. They allow developers to specify options or parameters when running a script, making it more flexible and customizable. However, the process of parsing these arguments can be a tedious and error-prone task 5 min read Check multiple conditions in if statement - Python If-else conditional statement is used in Python when a situation leads to two conditions and one of them should hold true. Syntax:if (condition): code1else: code2[on_true] if [expression] else [on_false]Note: For more information, refer to Decision Making in Python (if , if..else, Nested if, if-elif 4 min read Check if all the values in a list that are greater than a given value - Python We are given a list of numbers and a target value, and our task is to check whether all the elements in the list are greater than that given value. For example, if we have a list like [10, 15, 20] and the value is 5, then the result should be True because all elements are greater than 5. This is use 3 min read Check If Dictionary Value Contains Certain String with Python We need to check if the value associated with a key in a dictionary contains a specific substring. For example, if we have a dictionary of user profiles and we want to check if any userâs description contains a particular word, we can do this easily using various methods. Letâs look at a few ways to 4 min read How to check whether specified values are present in NumPy array? Sometimes we need to test whether certain values are present in an array. Using Numpy array, we can easily find whether specific values are present or not. For this purpose, we use the "in" operator. "in" operator is used to check whether certain element and values are present in a given sequence an 2 min read Like