Arun Kumar Molugu
PRO
last week
Aruncountry asked

What is the meaning of the != symbol?

Abhay Jajodia
Expert
2 days ago
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 True when the values are different.

  • It returns False when 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.