Skip to main content

Python Falsy Values

One of the simplest, yet more common comparisons that engineers make is to check whether a value is True or False.

Knowing what is Falsy is crucial to avoid mistakes when doing such comparisons.

These are many of the falsy python values in the standard library!

{} # empty dictionary
() # empty tuple
[] # empty list
set() # empty set
range(0) # empty range, range(1,1), range(2,2), range(3,3) etc.. work as well
"" # empty string

b'' # empty bytes
bytearray(b'') # empty bytearray
memoryview(b'') # empty memoryview

0 # zero as integer
0.0 # zero as float
0j # zero as complex
datetime.timedelta(0) # zero time difference

None
False