-1

I put exit function in "except" section in try, except in python but it doesn't work. and 'finally' block still execute. I supposed program should stop after exit() function but it didn't. I will be appreciated it if you tell me why.

# Constants ===============================
List = [1,2,3]

# -----------------------------------------

# Functions ===============================
def main():
  try:
    print(List[4])
    
  except Exception as e:
    print(e)
    exit()
    
  finally:
    print("The 'finally' block.")
    
# -----------------------------------------
if __name__ == '__main__':
  main()
  

0 Answers0