May-31-2018, 07:11 PM
See my example in the previous post.
Every non-empty string is True.
Whatever the name is, the if statement will be True.
Here is the example:
Here you can see how all the logical operators work:
Every non-empty string is True.
>>> bool('Tom') True >>> bool('Victor') TrueSo
False or True
is True. True or True
is also True.Whatever the name is, the if statement will be True.
myName == 'Tom' or 'Jerry'
can be translate to (myName == 'Tom') or 'Jerry'
. So it becomes False or True
which is True or True or True
which is also True.Here is the example:
>>> myName = 'Vanessa' >>> bool(myName == 'Tom' or 'Jerry') TrueObviously myName is not Tom or Jerry but still this condition evaluates to True. Because 'Jerry' evaluates to True and the or operator.
Here you can see how all the logical operators work:
>>> True and False False >>> True and True True >>> False and True False >>> False or True True >>> False or False False