Just starting to learn Python, and encounter a problem
MRAB
python at mrabarnett.plus.com
Sat Jul 23 15:06:31 EDT 2016
On 2016-07-23 19:18, gst wrote:
> Heuh case 2 :
>
> "String1" or "String2"
>
> Evaluates to "String1" ?
>
Suppose you have:
x or y
If bool(x) returns True, then the result will be x, else the result will
be y.
Example 1:
bool("String1") returns True, therefore the result of:
"String1" or "String2"
is "String1".
Example 2:
bool("") returns False, so the result of:
"" or "String2"
is "String2".
(The empty string "" is considered 'false-y'; all other strings (i.e.
all non-empty strings) are considered 'true-y'.)
More information about the Python-list
mailing list