Reputation: 131647
What is the meaning of <> in Python?
I have tried searching for it on Google but I cannot seem to get inside the search term...
I have not seen this in any other language also otherwise I would have tried to find it.
Upvotes: 6
Views: 1271
Reputation: 2889
the <> operator is the same as != which means not equal to
if thing1 <> thing2:
code here
Upvotes: 0
Reputation: 10482
It is an obsolete inequality operator. See the Python documentation.
!= can also be written <>, but this is an obsolete usage kept for backwards compatibility only. New code should always use !=.
Upvotes: 3
Reputation: 131647
<>
means not equal to
. <>
and !=
have the same meanings.
From the docs:
The forms <> and != are equivalent; for consistency with C, != is preferred; where != is mentioned below <> is also accepted. The <> spelling is considered obsolescent.
Upvotes: 1
Reputation: 31053
<>
is an alternate spelling of !=
, the inequality test operator. IIRC, it has been removed in Python3.
>>> "foo" <> "bar"
True
>>> "foo" <> "foo"
False
Upvotes: 15