if throw error python code example
Example 1: throw error python
raise Exception("Error")
Example 2: python exception
try:
# code block
except ValueError as ve:
print(ve)
Example 3: python catch any exception
try:
do_something()
except:
print "Caught it!"