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 trialPetar Nedeljkovic
699 PointsI don't get why the code at 2:25 doesn't work
If the "raise" function raises a value error when the number of people is bellow or equal to 1, then shouldn't that error trigger the "except" function? Why is the amount_due = split_check(total_due, number_of_people) line even ran if it's under "else"? shouldn't the "else" function only be ran when there are no errors?
1 Answer
KRIS NIKOLAISEN
54,972 PointsThe split_check function and try block are separate. Except will execute only if there is an error in the try. At 2:25 there are no errors in the try (20 is converted to float and zero is converted to integer) so the else executes. That is when the error is raised from within the split_check function and the program ends.