Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Does this value count as True or False?

x = 23

if x:
    print("23 is true")

if x != 0:
    print("23 is true")

y = 0
if y:
    print("0 is true")
else:
    print("0 is false")

if y != 0:
    print("0 is true")
else:
    print("0 is false")

# 23 is true
# 0 is false