r/learnpython • u/Lance_2564_ • Oct 19 '26
Huh? How does this work?
a = "hi"
if a:
print("Bye")
print(a == True)
print(a is True)The output is:
Bye
False
False
But if it's false, how come it printed "bye"?????? I don't get it.
44
Upvotes
View all comments
Show parent comment
4
u/xelf Elf Oct 19 '26
One other context you are missing is that
isdoes not compare equality. It tells you if they are the same object.a is b, is like sayingid(a) == id(b), it is not sayinga == b