PRO
Arun
asked

Expert
Abhay Jajodia answered
Hello Arun! The != symbol is known as the "not equal to" operator in Python. It checks whether two values are not equal to each other. Here's how it works:
It returns
Truewhen the values are different.It returns
Falsewhen the values are the same.
For example, in the code you're working with:
number = 21
# This will print False because 21 is equal to 21
print(number != 21)
# This will print False because 50 is equal to 50.0
print(50 != 50.0)
# This will print True because 21 is not equal to 21.1
print(number != 21.1)In the first two cases, both values are equal, so it prints False. In the last case, 21 is not equal to 21.1, so it prints True.
Keep practicing with these comparison operators, and you'll get the hang of them! If you have more questions, feel free to ask!
Python
This question was asked as part of the Learn Python Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer
