Python: True, False

By Xah Lee. Date: . Last updated: .

In Python:

Following evaluates to false:

# -*- coding: utf-8 -*-
# python

if True:                        # yes
    print "yes"
else:
    print "no"

if 3:                           # yes
    print "yes"
else:
    print "no"

if "abc":                       # yes
    print "yes"
else:
    print "no"
# -*- coding: utf-8 -*-
# python

if False:                       # no
    print "yes"
else:
    print "no"

if None:                        # no
    print "yes"
else:
    print "no"

if []:                          # no
    print "yes"
else:
    print "no"

if 0:                           # no
    print "yes"
else:
    print "no"

if "":                          # no
    print "yes"
else:
    print "no"