Last Updated: May 22, 2026
A try block can do more than catch errors. Python adds two optional clauses, else and finally, that solve problems except alone cannot. else holds code that should run only when nothing went wrong. finally holds cleanup that has to happen regardless of what went wrong. This lesson covers when each one runs, why they exist, how they interact with return, the trap of returning from finally, and how the whole pattern compares to a with statement.