using assert statement for sanity checks

PHOTO EMBED

Tue Jun 18 2024 04:13:23 GMT+0000 (Coordinated Universal Time)

Saved by @pynerds #python

def divide(a, b):
    assert b != 0
    print(f"{a} / {b} = {a/ b}")

divide(10, 2)
divide(10, 0)
content_copyCOPY

https://www.pynerds.com/assert-statement-in-python/