Objective
Create a Python program that extracts the important information from a traceback, the message that Python shows when an exception is not caught.
Instructions
- Read an integer
nand thennlines of a simplified traceback. All but the last one have the formatFile "name", line N, in function. The last one is the error:Type: message(or justTypeif there is no message). - The error happened on the last
Fileline (the innermost one). To separate its parts, usesplit(", "). - Show four lines:
Exception: Type,Message: text(orMessage: -if there is none),Line: NandFunction: name. - Show a fifth line,
Calls: K, with the number ofFilelines.
3
File "main.py", line 10, in <module>
File "main.py", line 4, in dividir
ZeroDivisionError: division by zero
Exception: ZeroDivisionError
Message: division by zero
Line: 4
Function: dividir
Calls: 2
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise