I have a very basic snippet of code.
print("a" or "b")
>> a
I'm not entirely sure what I expected to happen. Why does this print "a", and in general how are strings handled with python control flow?
I have a very basic snippet of code.
print("a" or "b")
>> a
I'm not entirely sure what I expected to happen. Why does this print "a", and in general how are strings handled with python control flow?
In python, empty strings evaluate to False
in a boolean context, while non-empty strings are True
.