Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Python: How tocatch several exceptions

Python: How tocatch several exceptions
{filelink=16547}

def division(x, y):
      try:
          return(x/y)
      except ZeroDivisionError:
          print "Cannot divide",x,"by zeo"  
      except TypeError, e:
          print e  # Type exception
#Main
print division(4,2)
print division(1,0)
print division("1",2)#unsupported operand type(s) for /: 'str' and 'int'

Users who found this page were searching for:

  • python time.asctime() format
  • how to send a mail from java file
  • format date using java calendar
  • create a python program class

No comments yet.

Leave a Comment