3 ms·
That's probably because $ python >>> int(True) 1 >>> int(False) 0
by achanda358 9y ago
That's probably because
$ python
>>> int(True)
1
>>> int(False)
0
- masklinn 9y agoNo, that's because (for historical reasons of booleans having only been added in Python 2.3[0]) >>> issubclass(bool, int) True >>> True == 1 True >>> False == 0 True [0] https://www.python.org/dev/peps/pep-0285/ https://www.python.org/dev/peps/pep-0285/
- kbp 9y agoThat doesn't explain why, because there's no implicit conversion to int when adding things, eg: >>> s = '12' >>> int(s) 12 >>> s + s '1212'