0
Can somebody provide your reason for the below statement? 2==2.0 returns true. Why it is returning true?
2==2.0 returns true. Somebody describe how this could be true. type(2) returns int class type(2.0) returns float class V3.7 Python interpreter
1 Respuesta
+ 3
It checks the value. not the type; the statement checks if 2 equals 2, not if an int equals a float.
EDIT: a further example, you could check if they are both the same type this way:
if type(2.0) == type(2):
print("True")
else:
print("False")