LearnPy Hub
← Context Managers problems
Medium

Record the Error, Keep Going

Write a class Recorder whose __exit__ saves the exception message in self.error (or None) and returns True. For each input line, inside with Recorder() as r: print 100 // int(line); after the block print error: MESSAGE if r.error is set.

Input

n, then n lines.

Output

Lines.

Sample 1

Input
3
5
0
x
Output
20
error: integer division or modulo by zero
error: invalid literal for int() with base 10: 'x'

Sample 2

Input
1
7
Output
14
solution.py
Output appears here
Record the Error, Keep Going · Python practice problem · LearnPy Hub