-1

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?

1

1 Answer 1

1

In python, empty strings evaluate to False in a boolean context, while non-empty strings are True.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.