david
answered Sep 19 '21 00:00
Python has operator module.
operator module have also not equal to (ne()) method which had same funcationality as != (not equal) opeator.
!= and operator.ne() both work same .
you need to import operator module as below.
import operator
after importing the operator module, now use operator.ne(first value (or variable),second value( or variable))
operator.ne(a,b) returns True if both passed argument's value is not equal or False if both passed argument's value is equal,
x=102
y=102
if(operator.ne(x,y))
# do code here for a and b are not equal
in above code operator.ne(x,y) return False
x="102"
y=102
if(operator.ne(x,y))
# do code here for a and b are not equal
in the above code operator.ne(x,y) return True. because Python is a Strongly Typed programming language. and x have string type value and y have integer value so there not equal in type so it returns False
operator.ne() is check value and type both