I am trying to handle exceptions gracefully such that when a user enters a character, when a number is expected, he is notified with a custom warning/message.
I know that the try, catch has the following syntax:
I have been trying something like this, to no avail:
number = input('Enter number');
warning('NOT A NUMBER');
I do not understand why the above code fails since
assert if it is false, displays the error message 'Assertion Failed'.
I know that using
catch is a bit of a sledgehammer approach, but I would like to understand how to implement the above functionality. Any tips would be appreciated.