Medium
Swallow One Error Type
Write a class context manager
Ignore(exc_type) whose __exit__ returns True when the exception matches, so it is swallowed. Using Ignore(KeyError), look up each input key in {'a': 1, 'b': 2} and print the value; then print ok.Input
One line of keys.
Output
Lines.
Sample 1
Input
a x b
Output
1 2 ok
Sample 2
Input
z
Output
ok
Output appears here