This question already has an answer here:
- Python not equal operator 4 answers
Perhaps this is a rather newbie-ish question, but I'm curious. I have tried searching for it, but I suppose I lack the correct terminology to search properly.
Difference between !=
and <>
.
On searching again, "inequality", I found one that discusses not ==
and !=
, but nothing about <>
.
They are interchangeable in Python 2, but
<>
is deprecated and has been removed in Python 3.Also if you want to use
<>
in Python 3.X, you can import this from future module.In Python 2.x,
<>
is equivalent to!=
, as described in the documentation:In Python 3.x,
<>
has been removed. Again, the documentation says: