Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: difference between != and <>? [duplicate]

So, I'm making a python cheat sheet for myself, and when I started covering comparison operators, I noticed these two:

a = 1
b = 2

if a != b:
 print("Dunno")

if a <> b:
 print("Dunno")

I'm using python 2.7 and was curious if there's a difference between the two operators?

like image 585
user2528030 Avatar asked Oct 29 '25 16:10

user2528030


2 Answers

As described in the documentation, they are the same. <> is deprecated and was removed in Python 3, so you should use !=.

like image 70
BrenBarn Avatar answered Nov 01 '25 06:11

BrenBarn


<> is deprecated. Other than that, no.

like image 33
Ignacio Vazquez-Abrams Avatar answered Nov 01 '25 06:11

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!