Home  >  Article  >  Backend Development  >  What does != mean in python?

What does != mean in python?

silencement
silencementOriginal
2019-06-25 14:38:1698292browse

How to express not equal in python?

What does != mean in python?

#In Python language, use != to indicate inequality. We understand through the following simple example:

What does != mean in python?

In the above example, variables x and y are assigned values ​​first, and then the if statement is used to determine whether x and y are equal. , if they are not equal, print the value of x y; if they are equal, print the value of x - y. Obviously, x is not equal to y, and the result is the value of x y, which is 17. In the above example, != is the inequality symbol, which is formed by! Used in combination with =.

Another example, as follows

What does != mean in python?

We use Python to verify that 40 is not equal to 40, and the returned result is False, which is wrong ;Verify that 45 is not equal to 48, and the result returns True. Verify that list a and list b are equal. False is also returned because they are not equal!

So far, we have mastered how to express inequality in Python, which is represented by !=. Not only can it determine whether two numbers and lists are equal, it can also verify whether two strings, tuples, dictionaries, or sets are equal!

The above is the detailed content of What does != mean in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn