user225312
user225312

Reputation: 131647

what does <> mean in Python

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

Answers (5)

SourD
SourD

Reputation: 2889

the <> operator is the same as != which means not equal to

if thing1 <> thing2:
   code here

Upvotes: 0

Don
Don

Reputation: 17606

It is the same as != ("not equal")

Upvotes: 1

Gavin H
Gavin H

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

user225312
user225312

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

Dirk
Dirk

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

Related Questions