Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCollin Hadley
955 PointsJust out of curiosity, why would we raise exceptions when we could just do an else statement to produce the same result?
What does the "except" allow us to do that an "else" couldn't?
1 Answer
Steven Parker
231,275 PointsBesides handing exceptions that you raise yourself, an "except" can also catch exceptions caused by program errors. This functionality cannot be replicated with conditional statements.
Wesley Trayer
13,812 PointsWesley Trayer
13,812 PointsAlso, if you don't know what "if" statement would be required to catch an error that you're receiving, you can sometimes just "except" that error. (Of course, ideally, you do want to figure out why you're receiving an error before you mute it.)