Never use `assert` to raise exceptions. `assert` is removed when you run python with optimisation.