Why is the list printing 2 and not an empty string?

a. This is printing 2 because is the first assignment

![values2|690x85]
b. Why is this one printing 2 and not an empty string?
![values2|690x85]

Your two examples are the same.

Consider:

>>> '' or 2
2
>>> bool(2)
True
>>> bool('')
False
1 Like

Thanks. Can you please explain as to why bool(’ ') is False an not True because we gave a value which is an empty string?

1 Like

Empty strings have a boolean value of False in most languages.

Edit: Possibly all (I don’t know all languages.)
Edit #2: Ruby is an exception. Empty strings are truthy in Ruby. There are likely others.

1 Like