Playing around with isalpha()
, I have noticed some strange behaviour.
"a".isalpha()
>>True
"2".isalpha()
>> False
The two statements above, return what I would expect them to. However, now adding a tilde before, makes less sense.
~"a".isalpha()
>> -2
~"2".isalpha()
>> -1
Why does this happen? I have discovered that using not
instead of ~
returns the output I was expecting, but am interested in the behaviour above.
not "a".isalpha()
>> False
not "2".isalpha()
>> True