LearnPy Hub
← Exceptions problems
Medium

One except for Two Errors

IndexError and KeyError are both LookupErrors. A list is [10, 20, 30] and a dict is {'a': 1}. Read lines list i or dict k until END; print the value, or missing (ErrorName) using one except LookupError as e.

Input

Lines, then END.

Output

Lines.

Sample 1

Input
list 1
dict a
list 9
dict z
END
Output
20
1
missing (IndexError)
missing (KeyError)

Sample 2

Input
list -1
END
Output
30
solution.py
Output appears here
One except for Two Errors · Python practice problem · LearnPy Hub