Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python Basics!
You have completed Python Basics!
Preview
Let's learn how to raise our own exceptions to help prevent invalid values from being added.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now as it is,
if number of people comes in as zero,
0:00
we end up opening up that worm
hole with a zero division error.
0:00
Also, we end up allowing for a negative
amount of people to split a check,
0:05
which makes it look like the restaurant
actually owes us some money.
0:08
So, let's do this.
0:12
Let's verify that we have a good value,
and
0:14
we if we don't, let's let the caller
know that they've caused an exception.
0:16
So we need to make sure that
our value is greater than zero.
0:20
Well, actually, wait a second.
0:25
Why would you split
a check with one person?
0:27
That should probably
not be allowed either.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up