← Lesson
True, False, and None
Joeven
Run
Reset
Python loads on first run
result = 0 text = "" items = [] error = None print("bool(0) =", bool(result)) print("bool('') =", bool(text)) print("bool([]) =", bool(items)) print("error is None =", error is None) print("bool('0') =", bool("0")) print("bool([1]) =", bool([1])) if result: print("if result ran") else: print("if result skipped because 0 counts as no") if error is None: print("error is missing, not zero, not blank") print("0 or fallback =", result or "fallback") print("'' or guest =", text or "guest")
Run to execute this in your browser. Nothing is sent to a server.