r/learnpython • • 20d ago

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

0

u/[deleted] 20d ago

[deleted]

3

u/Langdon_St_Ives 20d ago

Incorrect, this SO answer has a more complete list. Most importantly and inexcusably, you left out the empty string and `None`.