def transact(funds, stocks, qty, price, buy=False, sell=False):

    """A bookkeeping function to help make stock transactions.

       Args:
           funds: An account balance, a float; it is a value of how much money
           you have,
                  currently.

           stocks: An int, representing the number of stock you currently own.

           qty: An int, representing how many stock you wish to buy or sell.

           price: An float reflecting a price of a single stock.

           buy: This option parameter, if set to true, will initiate a buy.

           sell: This option parameter, if set to true, will initiate a sell.

       Returns:
           Two values *must* be returned. The first (a float) is the new
           account balance (funds) as the transaction is completed. The second
           is the number of stock now owned (an int) after the transaction is
           complete.

           Error condition #1: If the `buy` and `sell` keyword parameters
           are both set to true, or both false. You *must* raise an
           ValueError exception with an appropriate error message since this
           is an ambiguous transaction.

           Error condition #2: If you buy, or sell without enough funds or
           stocks to sell, respectively.  You *must* raise an
           ValueError exception with an appropriate error message since this
           is an ambiguous transaction.
    """

    if(buy is False and sell is False):
        # the 'raise' keyword is followed by the instance of exception type
        # (ValueError) which is
        # given a custom description ("Ambiguous transaction...")
        raise ValueError("Ambiguous transaction! Can't determine whether to"
                         "buy or sell!")

    if(buy is True and sell is True):
        # the 'raise' keyword is followed by the instance of exception type
        # (ValueError) which is
        # given a custom description ("Ambiguous transaction...")
        raise ValueError("Ambiguous transaction! Can't determine whether to"
                         "buy or sell!")

    if(buy is True and sell is False):
        if(float(funds) < float(qty*price)):

            # the 'raise' keyword is followed by the instance of exception type
            # (ValueError) which is
            # given a custom description ("Ambiguous transaction...")
            raise ValueError(f"Insufficient funds to purchase {qty} stock at"
                             "${price:0.2f}!")
            return funds, stocks

        else:
            stocks = int(qty + stocks)
            funds = float(funds - (price*qty))
            return funds, stocks

    if(buy is False and sell is True):
        if(stocks < qty):
        
            raise ValueError(f"Insufficient stock owned to sell {qty} stocks!")
            return funds, stocks
        else:
            stocks = int(stocks - qty)
            funds = float(funds + (price*qty))
            return funds, stocks