How to express not equal in python?
#In Python language, use != to indicate inequality. We understand through the following simple example:
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
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!