Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python try and except

'''
We can use try and except to continue running code even if we
come across an error.
'''

try:
  var = 0 / 0 # Runs into error
except ZeroDivisionError as e: 
  print(e) # Prints the error
  
  #  ADD ANY OTHER CODE YOU WANT TO EXECUTE
Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
5+7 =