What is operation of <> in Python?



The <> operator is available in Python 2.x as not equal to operator. there is also != operator for the same operation. In Python 3.x, <> operator is deprecated.

Python 2.7

>>> a=5                                                                                                                                                
>>> b=7                                                                                                                                                
>>> a<>b                                                                                                                                              
True                                                                                                                                                  
>>> a!=b                                                                                                                                              
True  

Python 3

>>> a=5
>>> b=6
>>> a!=b
True
>>> a<>b
SyntaxError: invalid syntax

Advertisements