+ 1
what is == used for
give me links were they r
4 Answers
+ 2
It is often said = != ==
It means = (assignment operator) is != (not equal to) == (the equality operator)
= is used to assign values to variables.
== is used to check equality. 2 == 2 will return True.
!= is inequality operator to check if values are not equal. 2 != 2 will return False.
+ 2
Tests equality between two values:
1 == 1
# returns True
1 == 2
# returns False
Itâs different from =, since = assigns a value:
x = 1
# now x has the value of 1
x == 1
# returns True
x == 2
# returns False
It works for more than just numbers:
âheyâ == âheyâ
# returns True
You should really play with these on code playground or somewhere else. Works better.