In Python any non-zero integer value is true; zero is false. : Boolean « Data Type « Python





In Python any non-zero integer value is true; zero is false.

In Python any non-zero integer value is true; zero is false.
a = 0 
if a:
   print "Here"
   
a = 2

if a:
   print "There"        

           
       










Related examples in the same category

1.Boolean operation in ifBoolean operation in if
2.Anything with a non-zero length is true, empty sequences are falseAnything with a non-zero length is true, empty sequences are false