Use !=. See comparison operators. For comparing object identities, you can use the keyword is and its negation is not.

e.g.

1 == 1 #  -> True
1 != 1 #  -> False
[] is [] #-> False (distinct objects)
a = b = []; a is b # -> True (same object)
Answer from tskuzzy on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-not-equal-operator
Python NOT EQUAL operator - GeeksforGeeks
July 23, 2025 - It returns True if operands on either side are not equal to each other, and returns False if they are equal. ... Note: It is important to keep in mind that this comparison operator will return True if the values are the same but are of different ...
Discussions

What is the correct way to write a not equal Python condition? - TestMu AI Community
I’m trying to understand how to use the not equal Python operator in an if or elif statement. I know == is used for equality, but what’s the proper syntax to say “does not equal” in Python? For example, how should I rewrite this line? elif hi (does not equal) bye: Is there a specific ... More on community.testmuai.com
🌐 community.testmuai.com
0
July 3, 2025
deprecated - Python not equal operator - Stack Overflow
I come from a c style languages, so I am natural in using != as not equal, but when I came to Python, from the documentation I read, I learned that for this purpose the operator is used. More on stackoverflow.com
🌐 stackoverflow.com
Not equal operators
js is arguably !== More on reddit.com
🌐 r/ProgrammerHumor
190
3088
December 19, 2020
No .equals()?
You can use == to compare strings in C, too. Just...not how you're thinking. More on reddit.com
🌐 r/ProgrammerHumor
252
4386
January 24, 2023
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-not-equal-operator
Python not equal operator | DigitalOcean
August 3, 2022 - Python not equal operator returns True if two variables are of same type and have different values, if the values are same then it returns False.
🌐
freeCodeCamp
freecodecamp.org › news › python-not-equal-how-to-use-the-does-not-equal-operator
Python Not Equal – Does Not Equal Operator Tutorial
January 7, 2022 - a = 21 b = 10 if ( a != b ): print ("True. a is not equal to b") else: print ("False. a is equal to b") # True. a is not equal to b · The if statement checks whether the values of the operands are not the same and then prints a message based on the value returned. This is a very basic example. As you advance as a Python developer, you'll find yourself crafting more complex (but not necessarily hard) logic to execute various commands.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
3 days ago - Non-identical instances of a class normally compare as non-equal unless the class defines the __eq__() method. Instances of a class cannot be ordered with respect to other instances of the same class, or other types of object, unless the class ...
🌐
FavTutor
favtutor.com › blogs › python-not-equal-operator
Not Equal Operator in Python
October 7, 2023 - The not equal operator (!=) allows us to compare two or more values and determine if they are not equal. We saw examples of using the not equal operator with different data types and how it can be used in control statements like if statements.
Find elsewhere
🌐
Server Academy
serveracademy.com › blog › python-not-equal-tutorial
Python Not Equal Tutorial - Server Academy
July 10, 2024 - Introduction In this article, we are going to cover the “not equal” operator (!=) in Python. The != operator, which stands for “not equal to,” is crucial for checking if two values or variables are different.
🌐
TestMu AI Community
community.testmuai.com › ask a question
What is the correct way to write a not equal Python condition? - TestMu AI Community
July 3, 2025 - I’m trying to understand how to use the not equal Python operator in an if or elif statement. I know == is used for equality, but what’s the proper syntax to say “does not equal” in Python? For example, how should I rewrite this line? elif hi (does not equal) bye: Is there a specific operator like != that works for not equal Python comparisons?
🌐
DataCamp
datacamp.com › tutorial › not-equal-python
How to Use the Python 'Not Equal' Operator | DataCamp
February 14, 2024 - Comparing values in Python to check if they are not equal is simple with the != operator. Check out this tutorial on how to use Python’s not equal operator.
🌐
Mimo
mimo.org › glossary › python › inequality-operator
Python Not Equal Operator: Master Comparison in Python
If a == b is True, then a != b is False. It Compares Values: != checks if the values of two variables are different. This is distinct from the is not operator, which checks if two variables refer to different objects in memory. It is Type-Sensitive: In Python, comparing values of different ...
🌐
Kanaries
docs.kanaries.net › topics › Python › does-not-equal-python
What Is Does Not Equal In Python? – Kanaries
3 weeks ago - PyGWalker (opens in a new tab) ... exploration. ... The not equal operator in Python is represented by the symbol !=. It compares two values or objects and returns True if they are not equal, and False otherwise....
🌐
Python documentation
docs.python.org › 3 › reference › expressions.html
6. Expressions — Python 3.14.3 documentation
5 days ago - Comparison operators implement a particular notion of what the value of an object is. One can think of them as defining the value of an object indirectly, by means of their comparison implementation. Because all types are (direct or indirect) subtypes of object, they inherit the default comparison behavior from object. Types can customize their comparison behavior by implementing rich comparison methods like __lt__(), described in Basic customization. The default behavior for equality comparison (== and !=) is based on the identity of the objects.
🌐
Zero To Mastery
zerotomastery.io › blog › python-not-equal
Beginner's Guide To The Python ‘Not Equal’ Operator (!=) | Zero To Mastery
August 22, 2024 - The != operator is equally powerful when working with strings. It checks whether two strings have different content, which is essential in many text-based applications. ... Ensuring user input meets certain criteria or comparing text data for ...
🌐
Learn Coding Fast
learncodingfast.com › home › how to determine if two values are not equal in python
How to Determine If Two Values Are Not Equal in Python | Learn Coding Fast
December 18, 2020 - The most direct way to determine if two values are not equal in Python is to use the != operator (Note: There should not be any space between !
🌐
CodeGym
codegym.cc › java blog › learning python › python not equal operator
Python Not Equal Operator
December 18, 2024 - The != symbol is widely used and is considered the standard for Python. The <> symbol was used in earlier versions of Python but is now mostly seen in legacy code. For modern code, always use !=. Here’s a simple example of how to use the not equal operator:
🌐
AskPython
askpython.com › home › python not equal operator
Python Not Equal operator - AskPython
August 6, 2022 - Python not equal operator returns True if both the operands are not of the same type and value. Implement __ne__() function for not equal with custom objects.
🌐
iO Flood
ioflood.com › blog › python-not-equal
Python Not Equal | Functional Usage of != Python Operator
July 1, 2024 - The ‘not equal’ operator is represented by ‘!=’. It’s one of the comparison operators in Python used to compare two values. The operator returns True if the values are not equal and False if they are equal.
🌐
Codingem
codingem.com › home › python not equal operator (!=): a complete guide (with examples)
Python Not Equal Operator (!=): A Complete Guide (with Examples)
November 1, 2022 - Python not equal operator checks if a value is not equal to another. The not equal operator is !=. For example 10 != 20 returns True