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)
![Alexandra Wakefield](https://secure.gravatar.com/avatar/294df1b6c79e53cac5857a51d1718747?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Alexandra Wakefield
Courses Plus Student 382 Pointserr is calling class, but is not finding raise within the function
While using err
allowed me to clean up the error message within the console, it is not grabbing the message prompted after raise
within the function. Instead, it only calls <class 'ValueError'>
and similarly with ZeroDivisionError. What is preventing the message from showing and how do I unblock this prevention?
def splitCheck(totalAmount, totalCustomers):
amountDue = round(totalAmount / totalCustomers, 2)
if totalAmount <= 0:
raise ValueError("Remember: Insert the number needing to be paid.")
if totalCustomers <= 1:
raise ValueError or ZeroDivisionError("Remember: You need more than 1 person to split a check.")
print("Each person will pay ${}.".format(amountDue))
try:
totalAmount = float(input("How much is the check? "))
totalCustomers = int(input("How many people are paying? "))
splitCheck(totalAmount, totalCustomers)
except ValueError or ZeroDivisionError as err:
print("Oh no! That didn't look like a valid number.\nPlease, try again.")
print("{}".format(err))
Thanks, in advance.
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsI'm not sure what you were intending the "or" to do, but it will return the first operand that is not "falsey" (so in this case, ValueError — with no message).
You have a similar issue with the except, but there you can catch multiple exceptions by using a tuple:
except (ValueError, ZeroDivisionError) as err: