May 29, 2021 Article blog
Python is becoming more and more widely used in life, many small partners have taught themselves Python programming, but many small partners have encountered Python does not mean how to express this problem, today W3Cschool editor-in-chief to share their own experiences.
In the Python language, "does not equal" is usually represented by
!=
for example:
>>> x=1
>>> y=2
>>> if x !=y:
print(x+y)
else:
print(x-y)
3
In the simple code above, we assign 1 and 2 to
X
Y
variables, and then use
if
statement to make the judgment that X is not equal to Y, and
X+Y
the two variables are not equal
x !=y
X=Y
So the conditions that are often used on a daily basis≠0 how to fight?
In Python, not equal to
!=0
can be represented by ! .
I believe you see that here has fully mastered Python does not mean how to express, hope to help you, want to learn more relevant knowledge can go to Python column to learn.