prev | exception handling in python using Try block #exception handling in python def sum_fun(): try: #should contain normals operations / statements 1/0 except : #this part will be execute, if there is an error in try part. print "Oops!!! Invalid" else: #if try doesn't contain any errors this will be executed. print 'No error' finally: #This will be executed always - regardless of whether there is error in try part or not. print "Let's go home " #calling the function. sum_fun() |
next |