Question
What is the difference between `try-except` and `try-except-else-finally` blocks?
Asked by: USER5877
81 Viewed
81 Answers
Answer (81)
`try-except` handles errors. `try-except-else-finally` provides more granular control. The `else` block executes only if *no* exceptions occur in the `try` block, and the `finally` block always executes, regardless of exceptions. This allows you to separate code that should run only on success from cleanup code.