Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106381

Re: i cant seem to figure out the error

From Jason Friedman <jsf80238@gmail.com>
Newsgroups comp.lang.python
Subject Re: i cant seem to figure out the error
Date 2016-04-03 11:34 -0600
Message-ID <mailman.402.1459704900.28225.python-list@python.org> (permalink)
References <CABMxrODHsfZuSUSWT1AkBDAUzC9U5=MheXQv01QOsTNiSE2a=w@mail.gmail.com>

Show all headers | View raw


>
>    - Create a method called `withdraw` that takes in cash withdrawal amount
>    and updates the balance accordingly. if amount is greater than balance
>    return `"invalid transaction"`
>
>   def withdraw(self, amount):
>     self.amount=amount
>     if(amount > self.balance):
>       return ("Amount greater than available balance.")
>     else:
>   self.balance -= amount
>     return self.balance
>

The instructions say to "return 'invalid transaction'" but I expect they
really want that error printed to STDERR (typically your screen) rather
than literally returned.  Try this:

  def withdraw(self, amount):
    self.amount=amount
    if(amount > self.balance):
      print "Amount greater than available balance, no funds withdrawn."
    else:
      self.balance -= amount
    return self.balance

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: i cant seem to figure out the error Jason Friedman <jsf80238@gmail.com> - 2016-04-03 11:34 -0600

csiph-web