the programmer would need to insert code to check whether the type conversion had returned none programmer who forgot that check would run the risk of getting some strange error during program execution with exceptionsthe programmer still needs to include code dealing with the exception howeverif the programmer forgets to include such code and the exception is raisedthe program will halt immediately this is good thing it alerts the user of the program to the fact that something troublesome has happened (andas we discussed in the last overt bugs are much better than covert bugs moreoverit gives someone debugging the program clear indication of where things went awry if it is possible for block of program code to raise more than one kind of exceptionthe reserved word except can be followed by tuple of exceptionse except (valueerrortypeerror)in which case the except block will be entered if any of the listed exceptions is raised within the try block alternativelywe can write separate except block for each kind of exceptionwhich allows the program to choose an action based upon which exception was raised if the programmer writes exceptthe except block will be entered if any kind of exception is raised within the try block these features are shown in figure exceptions as control flow mechanism don' think of exceptions as purely for errors they are convenient flow-ofcontrol mechanism that can be used to simplify programs in many programming languagesthe standard approach to dealing with errors is to have functions return value (often something analogous to python' noneindicating that something has gone amiss each function invocation has to check whether that value has been returned in pythonit is more usual to have function raise an exception when it cannot produce result that is consistent with the function' specification the python raise statement forces specified exception to occur the form of raise statement is raise exceptionname(argumentsthe exceptionname is usually one of the built-in exceptionse valueerror howeverprogrammers can define new exceptions by creating subclass (see of the built-in class exception different types of exceptions can have different types of argumentsbut most of the time the argument is single stringwhich is used to describe the reason the exception is being raised