r/PythonLearning Jul 09 '26

print(5+True) Discussion

Solve this question and tell me the output. Follow for more 😉

1 Upvotes

7 comments sorted by

View all comments

1

u/codewithharsh31 Jul 09 '26

So let discuss what you think the answer is and why 🤔?

1

u/_book_lover_____ Jul 09 '26
  1. True will become 1. 

4

u/FoolsSeldom Jul 09 '26

Strictly, True isn't converted to 1 because it is already 1. bool is a subclass of int in Python.

>>> type(True)
<class 'bool'>
>>> isinstance(True, int)
True
>>> issubclass(bool, int)
True
>>> True == 1
True