How to use not equal operator in python

Python

How would you say does not equal?

Like

if hi == hi:
print "hi"
elif hi (does not equal) bye:
print "no hi"

Is there something equivalent to == that means "not equal"?
 

1
Answers

Replies

ou can use the not equal operator !=. This is used to perform the comparison of the object identities.


Example:


1 == 1 #  -> True


1 != 1 #  -> False


[] is [] #-> False (distinct objects)


a = b = []; a is b # -> True (same object)

 
 

If you want to unleash your potential in this competitive field, please visit the Python course page for more information, where you can find the Python tutorials and Python frequently asked interview questions and answers as well.

 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
To Top