`assert` is an anti-pattern. If you want to check pre-conditions, do the check and raise an appropriate error (likely `ValueError` in this case).