Last modified on 01 Oct 2021.

Try..Except

try: 
  # codes
except:
  # codes run if there is an exception
try: 
  # codes
except:
  # codes run if there is an exception
else:
  # no exception?
try:
  # try codes
except FileNotFoundError as fnf_error:
    print(fnf_error)
except AssertionError as error:
    print(error)

Other Errors, check this list.

Apply

Check str of float

element = 'mean'
try:
    print(float(element))
except ValueError:
    if element == 'mean':
        print('hello mean')

Notes with this notation aren't good enough. They are being updated. If you can see this, you are so smart. ;)