What does != mean in python?

silencement
Release: 2019-06-25 14:38:16
Original
98420 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template