New course! Every coder should learn Generative AI!
Try a free lesson+ 1
why does 3=="3" return false although they are of the same value? doesn't the == operator checks only for the type not the value
== operator
7 Answers
+ 5
== does check. Datatype affects value.
+ 6
3 is of datatype int.
"3" is of datatype str.
Thus they aren't the same.
+ 4
yeah the value is quite different 3 is a number and "3" is a string.. and both can't be equal.. unless u convert either of them to same type
+ 2
but what i got from the tutorial that the == operator doesn't check for the datatype isn't that right ?
+ 2
I got it . thank you 😀
+ 1
Bc the 3 is a string
0
If you write only 3 , it is considered as integer and if you write with "3" then it is considered as string. And == operator checks datatype of value.