3-1-5-15. Solution: Handling Input Errors

Here is our solution for what the revised party_planner function on the previous page could look like, using a try-except block:

def party_planner(cookies, people):
    leftovers = None
    num_each = None

        num_each = cookies // people
        leftovers = cookies
    except ZeroDivisionError:
        print("Oops, you entered 0 people will be attending.")
        print("Please enter a good number of people for a party.")

    return(num_each, leftovers)