Skip to content
C

Logging-Enhanced Divide Function

Easypython

Add logging (INFO for a successful division, ERROR for a failed one) to a function that divides two numbers, replacing what would otherwise be print() statements.

Approach: configure logging to print to the console (stdout) at INFO level, then have safe_divide(a, b) log an ERROR and return None when b is 0, or log an INFO message with the result otherwise.

Input: Two lines: a, then b.

Output: One line: the logged INFO message if b != 0, or the logged ERROR message if b == 0.

Input (stdin)

Output

Run your code to see output here...