if we execute this code and give it invalid inputit simply fails with an unfriendly error messagepython fahren py enter fahrenheit temperature: python fahren py enter fahrenheit temperature:fred traceback (most recent call last)file "fahren py"line in fahr float(inpvalueerrorcould not convert string to float'fredthere is conditional execution structure built into python to handle these types of expected and unexpected errors called "try exceptthe idea of try and except is that you know that some sequence of instruction(smay have problem and you want to add some statements to be executed if an error occurs these extra statements (the except blockare ignored if there is no error you can think of the try and except feature in python as an "insurance policyon sequence of statements we can rewrite our temperature converter as followsinp input('enter fahrenheit temperature:'tryfahr float(inpcel (fahr print(celexceptprint('please enter number'codepython starts by executing the sequence of statements in the try block if all goes wellit skips the except block and proceeds if an exception occurs in the try blockpython jumps out of the try block and executes the sequence of statements in the except block python fahren py enter fahrenheit temperature: python fahren py enter fahrenheit temperature:fred please enter number handling an exception with try statement is called catching an exception in this examplethe except clause prints an error message in generalcatching an exception gives you chance to fix the problemor try againor at least end the program gracefully