Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106381
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Jason Friedman <jsf80238@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: i cant seem to figure out the error |
| Date | Sun, 3 Apr 2016 11:34:52 -0600 |
| Lines | 25 |
| Message-ID | <mailman.402.1459704900.28225.python-list@python.org> (permalink) |
| References | <CABMxrODHsfZuSUSWT1AkBDAUzC9U5=MheXQv01QOsTNiSE2a=w@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de aWrCbjsFp+7acOw+tsgbVwLc7XOGrhB49IXwyCNNlkbQ== |
| Return-Path | <jsf80238@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.011 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'returned.': 0.07; 'cc:addr:python-list': 0.09; 'stderr': 0.09; 'subject:error': 0.11; 'accordingly.': 0.13; 'def': 0.13; 'received:io': 0.16; 'received:psf.io': 0.16; 'withdrawal': 0.16; '\xc2\xa0-': 0.16; 'skip:` 10': 0.18; '>': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'this:': 0.23; 'header:In-Reply- To:1': 0.24; 'error': 0.27; 'message-id:@mail.gmail.com': 0.27; 'print': 0.30; 'received:google.com': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'expect': 0.37; 'method': 0.37; 'say': 0.37; 'received:209': 0.38; 'subject:the': 0.39; 'takes': 0.39; 'rather': 0.39; 'called': 0.40; 'your': 0.60; 'balance': 0.64; 'funds': 0.77; 'balance,': 0.84; '\xc2\xa0and': 0.84; 'to:none': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=YlTzr9kuWjXdNbMa3H5xoUMlZCGz1kpAxGhvE6zlbSM=; b=vLQfF7E8CUpfyt87eXWga2f+MdmBi0o4EH6Q5MFOgou5PZF1+IS8PE/lxJWOkC0VOb 6RrrSlR0JaaQuOtXiXrK/9nhe3mAfsDV357uhTIwuQa6N/Vp3zUSZtVhwfUPmVaiEPLn Q/QHzJD0FRFTbcxofWIGfm9oshFI7YJekc/N4kGIteFosgiO2am5/ddw7jSF+BNyQMbZ oiw9YKOFNrgGpsF0Qh0BHPvJGlF1WpsPcmz1vimFaqg8w2mIvJxEddnmDKJX7DHW4KRt n8ZI/xZlF9037xVjISErq86MRGiw/Ffu9746nmh8Gtb+x+qUO5SQHATCOCckT2okUKM9 e+Ng== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=YlTzr9kuWjXdNbMa3H5xoUMlZCGz1kpAxGhvE6zlbSM=; b=DvEyxisu9j3Kyy7gwKkxR+WCOJAHsIYZ9vtot5DChX+A4O8bPXX1KH2fnmGM63GEo7 z+NjpXN89WXHhrV4t/PWas38IvMF4f2ei5zVJm0fDmFazwuL2c2OHCVidnbgcLI/snU1 X8NkgBM1hatmdWbMQm0+SwTUQIvh5v5JZLi7T+RTqLecSvrHU5uImijpRdqaQIyS4VjV 1HMjUwSK/iPL01e8fPTQVMrX6A+5RYroAH/8QDRcjncvaXmLG3BM4wVEMK22x/ze6WhL G9BIRbRfsNRWHbUwwoAgsIj1M3bZUKZzqNyBvp4nvljiKJWgOPtobmo4QaJU2SskSs4g X/Dg== |
| X-Gm-Message-State | AD7BkJJ50OI8pYM8ZNuksv+GZ9BeO8GRvYcuC8kx/aUNSE+FYC2OK9w5jtKAhllJDupkkXK9Nncs9WfHKCD0kg== |
| X-Received | by 10.140.151.204 with SMTP id 195mr18835747qhx.42.1459704892248; Sun, 03 Apr 2016 10:34:52 -0700 (PDT) |
| In-Reply-To | <CABMxrODHsfZuSUSWT1AkBDAUzC9U5=MheXQv01QOsTNiSE2a=w@mail.gmail.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:106381 |
Show key headers only | 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
Re: i cant seem to figure out the error Jason Friedman <jsf80238@gmail.com> - 2016-04-03 11:34 -0600
csiph-web