Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Consistent error Date: Mon, 4 Jan 2016 03:14:07 +1100 Lines: 25 Message-ID: References: <6f54629c-745f-4f75-a267-0f174cc1aea1@googlegroups.com> <2a7c4d1e-b7ba-4fb7-845f-440026af3b59@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de otB2fzpXB5BxBKipIl0r3waos1lUWEaPSrV/s9avq9jA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'jan': 0.11; 'subject:error': 0.11; 'def': 0.13; '2016': 0.16; 'add,': 0.16; 'algorithmic': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'rewritten': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fix': 0.21; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; "i've": 0.25; 'figure': 0.27; 'message-id:@mail.gmail.com': 0.27; 'comments': 0.30; 'error.': 0.31; 'largest': 0.31; 'know.': 0.34; 'thanks!': 0.34; 'gives': 0.35; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:209': 0.38; 'still': 0.40; 'chrisa': 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 :content-type; bh=OMBiOEwOr4JRCeXyo2srvqzcCnrbfAj3r8JI1gtJPS4=; b=WjFCzMfTzk9QHWI3cxN5Q1UVlncNqtqrlTRz9GTIXrg8OGDf0fGj895YhWiIEiLBP3 1t4L4IdDsLbLwFWxbmvlSjxdXXf0mpiChf6kvZuv8I1T3w91518pTQ8wS/WDBoz6m2A2 YVP5p5t1jPtT9KmU+KomNYXuJToBmHTHygwoI6IY0P5FH93DDp/5O0/CYlelq+4UCIxz OqS/q7lbsZ4DRaikjFH8EJsahCu0ibzdTl6r1IVuAbWo2a7hIpMW3OZAL+ebgp1iIai1 SZsixp3jl8oYCewl42uyOKuJXgFJ44kNFvNxo9A1CkU2zUsCIx5I8/A0Cl/h+AiQKcXF 4mGQ== X-Received: by 10.107.47.162 with SMTP id v34mr28509590iov.19.1451837647479; Sun, 03 Jan 2016 08:14:07 -0800 (PST) In-Reply-To: <2a7c4d1e-b7ba-4fb7-845f-440026af3b59@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101212 On Mon, Jan 4, 2016 at 2:59 AM, wrote: > Thanks Chris! > Don't worry about the indent, will fix it > I've rewritten it to this- > > def get_algorithm_result( numlist ): >> largest = numlist[0] >> i = 1 >> while ( i < len(numlist) ): > i = i + 1 >> if ( largest < numlist[i]): >> largest = numlist[i] >> numlist[i] = numlist[-1] >> numlist = [1,2,3,4,5] > return largest >> def prime_number(x): >> return len([n for n in range(1, x + 1) if x % n == 0]) <= 2 > > But it still gives the test_maximum_number_one error. > Please if you have any ideas what else I should change or add, let me know. Thanks! Well, the algorithmic comments I mentioned would still help you to figure out what's going on :) ChrisA