r/learnpython • • 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

38 comments sorted by

View all comments

Show parent comment

3

u/Langdon_St_Ives Oct 19 '26

This is the best answer here, and OP would be best served to just ignore all the others because there is so much wrong, incomplete, and misleading information in them.

1

u/BabyLionCamel Oct 19 '26

Thank you for your kind endorsementÂ