else and finally
A try statement has two more optional parts:
elseruns only if thetryblock raised nothing. Put follow-up work here, so thetryblock stays small and itsexceptcan't catch errors from the follow-up.finallyalways runs: after success, after a caught error, after an uncaught one, and even afterreturn. Use it for cleanup like closing a connection.
The order is try, except, else, finally.
The surprise is in the output: done with prints before the returned value.
finally runs on the way out of the function, before the caller gets the
result.
Never return inside finally. It throws away any exception in flight, and
Python 3.14 warns about it.
Run it, then add "5" to the inputs. Which part raises, and which clause
catches it?