user input and error handling the programmer can also raise exceptions in the code abovethe exceptions were raised by standard python functionsand we wrote the code to catch them instead of just letting python raise exceptionswe can raise our own and tailor the error messages to the problem at hand we provide two examples of such usecatching an exceptionbut raising new one (re-raisingwith an improved (tailorederror message raising an exception because of input data that we know are wrongalthough python accepts the data the basic syntax both for raising and re-raising an exception is raise exceptiontype(messagethe following code includes both examplesimport sys def read_altitude()tryh float(sys argv[ ]except indexerrorre-raisebut with specific explanationraise indexerror'the altitude must be supplied on the command line 'except valueerrorre-raisebut with specific explanationraise valueerrorf'altitude must be numbernot "{sys argv[ ]}' is read correctly as numberbut has wrong valueif raise valueerror( 'the formula is not valid for ={ }'return here we have defined function to handle the user inputbut the code is otherwise quite similar to the previous examples as abovethe except blocks will catch two different types of errorbutinstead of handling them ( stopping the program)the blocks here will equip the exceptions with more specific error messagesand then pass them on to be handled somewhere else in our program for this particular casethe difference is not very largeand one could argue that our first approach is simpler and therefore betterhoweverin larger programs it can often be better to re-raise exceptions and handle them elsewhere the last part of the function is differentsince the error raised here is not an error as far as python is concerned we can input any value of into our formulaandunless we input large negative numberit will not give rise to python error howeveras an estimate of air pressure the formula is only valid in the tropospherethe lower part of the earth' atmospherewhich extends from the lowest point on earth (on land)at if we set to be large negative numberthe argument for the exp function becomes large and positiveand leads to an overflowerror howeverthis error will occur only for values far outside the range of validity for our air pressure estimate