You could move these 2 definitions outside ``try`` and just check for ``ZeroDivisionError`` only in the division.