0
What's the difference between using 'finally' in my Python vs moving the "final" code out of the 'except' block?
try: print("may cause error") except: print("error-handling statement") finally: print("I always want this code to run at the end") 3rd print statement executes after if we take out 'finally'. Is finally just to make clean code?
2 Respostas
+ 6
Finally is always executed at the end of a try/except block regardless the outcome of the block
+ 5
Zoee it is not always that the code after the try/except block will run.
But if you use the code in finally it will always run.