To use try except for error handling

try:
      s=0
      g=s/0   # Division by zero creates error
      print 'Value of g :',g

except:
      print 'Something went wrong.'



try:
      s=0
      g=s/10   # Division by zero by 10  creates no error
      print 'Value of g :',g

except:
      print 'Something went wrong.'

No comments: