r/PythonLearning • u/saikat_hossen • 7d ago
Python Boolean
I'm having some trouble understanding Python boolean logic, it’s so simple to let it be confusing. Can anyone explain it to me in their own language?
2
Upvotes
r/PythonLearning • u/saikat_hossen • 7d ago
I'm having some trouble understanding Python boolean logic, it’s so simple to let it be confusing. Can anyone explain it to me in their own language?
2
u/ConsiderationNo9044 7d ago
There are two boolean values: True and False. You usually compare them using two operators,
andandor. They mean exactly as they do in plain English.True
andTrue = True, because both values are True.True
andFalse = False, because one value is False, andandmeans both must be true.True
orFalse = True, because one value is True, andormeans one value must be True. You can probably guess the result of FalseorFalse.Any non-zero number is Truthy, meaning it represents True, while zero represents False. Any non-empty strings and collections are also Truthy.