a. This is printing 2 because is the first assignment
b. Why is this one printing 2 and not an empty string?
![values2|690x85]
a. This is printing 2 because is the first assignment
Your two examples are the same.
Consider:
>>> '' or 2
2
>>> bool(2)
True
>>> bool('')
False
Thanks. Can you please explain as to why bool(’ ') is False an not True because we gave a value which is an empty string?
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.