Exceptions Lab¶
Learning Exceptions¶
Just a little bit for the basics.
Exceptions Lab¶
Improving input
- The
input()function can generate two exceptions:EOFErrororKeyboardInterrupton end-of-file(EOF) or canceled input. - Create a wrapper function, perhaps
safe_input()that returnsNonerather rather than raising these exceptions, when the user enters^Cfor Keyboard Interrupt, or^D(^Zon Windows) for End Of File. - Update your mailroom program to use exceptions (and IBAFP) to handle malformed numeric input