Answer the question
In order to leave comments, you need to log in
Why is string not equal to true?
A non-empty string in python is True , but comparing it to a boolean value yields False :
print("Hello world" == True)
# False
Answer the question
In order to leave comments, you need to log in
Non empty string in python is True
Here the string is not explicitly cast to the type bool
'a' == 'b'
would also be true, and both are True. if 'Hello world':
, in this case something like ->if bool('Hello world'):
if True:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question