---
title: "Comment by Alex Hall on \"Python Gotchas: 5 Worst Mistakes You Should Avoid\" | Hashnode"
description: "Since 0 is considered a &quot;Falsy&quot; value, then the comparison returns &#39;True`. No, that&#39;s the kind of thing JavaScript does. Most Falsy values (No"
url: "https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86"
---

[Discussion](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b)

Comment [Python Gotchas: 5 Worst Mistakes You Should Avoid](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b)

[Alex Hall](https://hashnode.com/@alexmojaki)

[Oct 27, 2020](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86)

> Since 0 is considered a "Falsy" value, then the comparison returns 'True\`.

No, that's the kind of thing JavaScript does. Most Falsy values (None, empty string/list/dict/etc) are not equal to False.

`False == 0` and `True == 1` because bool is a subclass of int. You can treat booleans just like those numbers, for example `True + True == 2`. This can be very useful.

[Miguel Brito](https://hashnode.com/@miguendes)

[Oct 27, 2020](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86#reply-5f989ac46ea7602886a170a6)

Interesting, thanks for the correction. I'll update the post.

Regardless, I wish it boolean wasn't subclass of ints.

IMHO, `True + True + True` shouldn't be equal to 3, or `False == 0`. This would avoid bugs such as the ones when using chained comparisons.

[Alex Hall](https://hashnode.com/@alexmojaki)

[Oct 27, 2020](https://hashnode.com/posts/python-gotchas/5f93f46afbdce372c9a56d6b/comment/5f98974b91c85e2865f5fb86#reply-5f989ea76ea7602886a170d5)

To me it seems obvious that the chained comparisons wouldn't work. I've never seen someone make that mistake before. Doing that breaks extremely easily without the fact about booleans. If `a == b == c` is True, then `(a == b) == c` is guaranteed to be False unless they are all equal to True (or 1).

I often use this property of booleans to write something like `sum(predicate(x) for x in lst)` to count the number of items in a list satisfying a condition, or conveniently making something plural with `f"thing{(len(things) > 1) * 's'}"`. It's hacky but it's fun.
