LearnPy Hub
← Exceptions problems
Medium

Raise From Another Error

Write parse_age(s): convert to int, and if that fails raise ValueError('bad age') from the original error. Read a line; on success print the age, otherwise print the message and the type name of e.__cause__.

Input

One line.

Output

One or two lines.

Sample 1

Input
25
Output
25

Sample 2

Input
twenty
Output
bad age
ValueError
solution.py
Output appears here
Raise From Another Error · Python practice problem · LearnPy Hub