Home >Backend Development >Python Tutorial >Python is not equal to how to write

Python is not equal to how to write

silencement
silencementOriginal
2019-05-15 17:50:3630167browse

How to express not equal in python?

Python is not equal to how to write

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

Python is not equal to how to write

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

Python is not equal to how to write

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 Python is not equal to how to write. 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