Q:

Use of <> in Python. Is <> an operator?

>>> 1<>1
False
>>> 1<>2
True
>>> 1<>3
True
>>> 1<>0
True
>>> 1<>1
False

What is the use of <> in Python?
Can someone help in explaining the above or the '<>' in general.

A:

It's the inequality operator, synonymous to !=. From the documentation:

The forms <> and != are equivalent; for consistency with C, != is preferred; where != is mentioned below <> is also accepted. The <> spelling is considered obsolescent.

The <> spelling has been removed in Python 3.

