Skip to main content

cash register

  # Adds an item to cash register.
    def addItem(self, price):
        while True:
            _itemCount = input('Enter your prices. Type "exit" when finished.')  # user enters temps w sentinel value option

            if _itemCount.lower == "exit":
                break

            try:

                _itemCount = int(_itemCount)  # converts input to int

            except ValueError:  # if user_input cannot be converted to int then print try again

                print('Please try again.')

            else:
                self._itemCount = self._itemCount + 1
                self._totalPrice = self._totalPrice + price