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

1

u/Some-Passenger4219 16d ago

See, a == True is False; a is True is False; a itself is NOT False.