Here is an example codes to use exception to display abnormal error
import traceback
kkk = [1,2,3,4]
for index in range(2,-1,-1):
try:
print(kkk[index+2])
except:
traceback.print_exc()
print('traceback.format_exc():\n%s' % traceback.format_exc())