I expected bool(1)
to equate to True using Python - it does - then I expected other integers to error when converted to bool
but that doesn't seem to be the case:
>>> x=23 #<-- replace with any integer
>>> bool(x)
True
What is happening? Am I misunderstanding bool(x)
- does this not convert x to a Boolean
data type?
A lot of comments about why I find this counter-intuitive. If I write the above like the below then, on first sight with no knowledge of the language, it would seem counter-intuitive:
>>>True == bool(23)
True