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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Mark Nembhard](https://secure.gravatar.com/avatar/ff16d556c674b5ad4a39d15d94b72d2a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mark Nembhard
1,387 PointsLogic of where the error is handled in the program. there seems to be 2 places
The example error in input for the total amount of people. I am confused over where it is handled? In the except block? Yes, but by simply adding the ValueError as err it seems to jump to the function block above then come back down to the except error block and then print both errors. Please clarify. the "as err". Is it that if a ValueError is raised, because it has that attribute("more than..."), will it use that punchline anytime it is activated even though it(the ValueErrror("More than..") is in the split_check function.
1 Answer
![Chris Freeman](https://uploads.teamtreehouse.com/production/profile-photos/1153532/micro_image.jpg)
Chris Freeman
Treehouse Moderator 68,425 PointsThe flow when using 20 and 0 as inputs is:
- define
split_check
function (lines 4-7) - run
try
block` (line 9)- get total input (line 10)
- get people input (line 11)
- call
split_check
(line 12)
- running `split_check (line 4)
-
raise
function is reached,ValueError
exception (line 6) - execution returned to calling line (line 12)
-
-
ValueError
caught bytry
section, jump toexcept
block -
except
line creates a reference to theValueError
object with the nameerr
(line 13)- print first message (line 14)
- print text from
err
(line 15)
When an error is raised, an error object is created with attributes for the error type, message string, and traceback information. If printed, the error object returns the string used to define the error object back when ValueError()
was called in line 6.
Post back if you need more help. Good luck!!