try except statements python code example
Example 1: python raise exception
# this raises a "NameError"
>>> raise NameError('HiThere')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: HiThere
Example 2: try except python
try: #try to do the following
print("Hi there")
except: #If what is meant to happen in (try) fails, do this.
print("A error happened with the code above")