diveintopython icon indicating copy to clipboard operation
diveintopython copied to clipboard

Typo in example 4.18 (and-or trick)

Open bbc2 opened this issue 11 years ago • 1 comments

Since a is an empty string, which Python considers false in a boolean context, 1 and '' evalutes to '', and then '' or 'second' evalutes to 'second'. Oops! That's not what you wanted.

bbc2 avatar Jul 31 '13 21:07 bbc2

It actually occurs a few times on that page.

bbc2 avatar Jul 31 '13 22:07 bbc2