dbutils.notebook.exit() will raise an exceptionIn the answer provided by @Shyamprasad Miryala above the print inside of except does not get printed because notebook.exit() text takes priority over any other print().Look at this example:%python a = ...