. However, note that != is preferred where <> is deprecated. Seeing as everyone else has already listed most of the other ways to say not equal I will just add: in this case it is simple switching the check of positive == (true) to negative and vise versa... You can use the != operator to check for inequality. Moreover in Python 2 there was <> operator which used to do the same thing, but it has been deprecated in Python 3. The standard operator module holds ne method which is a wrapper for != a.k.a. not equal operator. This is especially useful if you need to make comparisons in a setting where a function is expected. There are two operators in Python for the "not equal" condition - a.) != If values of the two operands are not equal, then the condition becomes true. (a != b) is true. b.) <> If values of the two operands are not equal, then the condition becomes true. (a <> b) is true. This is similar to the != operator. You can use "is not" for "not equal" or "!=". Please see the example below: The above code will print "true" as a = 2 assigned before the "if" condition. Now please see the code below for "not equal" The above code will print "not equal" as a = 2 as assigned earlier. Use != or <>. Both stands for not equal. The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent. (Reference: Python language reference) Start asking to get answers Find the answer to your question by asking. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.14.32835" /> . However, note that != is preferred where <> is deprecated. Seeing as everyone else has already listed most of the other ways to say not equal I will just add: in this case it is simple switching the check of positive == (true) to negative and vise versa... You can use the != operator to check for inequality. Moreover in Python 2 there was <> operator which used to do the same thing, but it has been deprecated in Python 3. The standard operator module holds ne method which is a wrapper for != a.k.a. not equal operator. This is especially useful if you need to make comparisons in a setting where a function is expected. There are two operators in Python for the "not equal" condition - a.) != If values of the two operands are not equal, then the condition becomes true. (a != b) is true. b.) <> If values of the two operands are not equal, then the condition becomes true. (a <> b) is true. This is similar to the != operator. You can use "is not" for "not equal" or "!=". Please see the example below: The above code will print "true" as a = 2 assigned before the "if" condition. Now please see the code below for "not equal" The above code will print "not equal" as a = 2 as assigned earlier. Use != or <>. Both stands for not equal. The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent. (Reference: Python language reference) Start asking to get answers Find the answer to your question by asking. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.14.32835" />
Communities for your favorite technologies. Explore all Collectives Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams Find centralized, trusted content and collaborate around the technologies you use most. Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. How would you say "does not equal"? Is there something similar to == that means "not equal"? Use !=. See comparison operators. For comparing object identities, you can use the keyword is and its negation is not. e.g. Not equal != (vs equal ==) Are you asking about something like this? This Python - Basic Operators chart might be helpful. There's the != (not equal) operator that returns True when two values differ, though be careful with the types because "1" != 1. This will always return True and "1" == 1 will always return False, since the types differ. Python is dynamically, but strongly typed, and other statically typed languages would complain about comparing different types. There's also the else clause: The is operator is the object identity operator used to check if two objects in fact are the same: You can use both != or <>. However, note that != is preferred where <> is deprecated. Seeing as everyone else has already listed most of the other ways to say not equal I will just add: in this case it is simple switching the check of positive == (true) to negative and vise versa... You can use the != operator to check for inequality. Moreover in Python 2 there was <> operator which used to do the same thing, but it has been deprecated in Python 3. The standard operator module holds ne method which is a wrapper for != a.k.a. not equal operator. This is especially useful if you need to make comparisons in a setting where a function is expected. There are two operators in Python for the "not equal" condition - a.) != If values of the two operands are not equal, then the condition becomes true. (a != b) is true. b.) <> If values of the two operands are not equal, then the condition becomes true. (a <> b) is true. This is similar to the != operator. You can use "is not" for "not equal" or "!=". Please see the example below: The above code will print "true" as a = 2 assigned before the "if" condition. Now please see the code below for "not equal" The above code will print "not equal" as a = 2 as assigned earlier. Use != or <>. Both stands for not equal. The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent. (Reference: Python language reference) Start asking to get answers Find the answer to your question by asking. Explore related questions See similar questions with these tags. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2025.8.14.32835