basic exception handling to handle exceptionsyou must tell python that you want to do so and then provide code to perform the handling tasks you have number of ways in which you can perform this task the following sections start with the simplest method first and then move on to more complex methods that offer added flexibility handling single exception in the ifelse py and other examples have terrible habit of spitting out exceptions when the user inputs unexpected values part of the solution is to provide range checking howeverrange checking doesn' overcome the problem of user typing text such as hello in place of an expected numeric value exception handling provides more complex solution to the problemas described in the following steps this example also appears with the downloadable source code as basicexception py open python file window you see an editor in which you can type the example code type the following code into the window -pressing enter after each linetryvalue int(input("type number between and ")except valueerrorprint("you must type number between and !"elseif (value and (value < )print("you typed"valueelseprint("the value you typed is incorrect!"the code within the try block has its exceptions handled in this casehandling the exception means getting input from the user using the int(input()calls if an exception occurs outside this blockthe code doesn' handle it with reliability in mindthe temptation might be to enclose all the executable code in try block so that every exception would be handled howeveryou want to make your exception handling small and specific to make locating the problem easier