Objective
Since Python 3.11, ExceptionGroup groups several errors into one and except* lets you handle each type separately. It is useful when a task accumulates errors instead of stopping at the first one.
Instructions
- The input is a line with values separated by spaces. For each value compute
100 // int(value)(integer) and store the result; if it fails withValueError(not an integer) orZeroDivisionError(it is zero), store the error in a list and carry on. - Show
Results: [...]with the list of results. If there are errors, raise anExceptionGroupwith all of them and handle it withexcept* ValueErrorandexcept* ZeroDivisionError, showingValueError: nandZeroDivisionError: nwith the number of errors of each type (only the types that appeared).
10 x 0 4 y
Results: [10, 25]
ValueError: 2
ZeroDivisionError: 1
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise