Consistent error

iykeluvzu at gmail.com iykeluvzu at gmail.com
Fri Jan 15 09:15:12 EST 2016


On Sunday, January 3, 2016 at 5:59:30 PM UTC+1, cc.fe... at gmail.com wrote:
> On Sunday, January 3, 2016 at 5:28:49 PM UTC+1, Ian wrote:
> > On Sun, Jan 3, 2016 at 8:59 AM,  <cc.fezeribe at gmail.com> 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
> > 
> > This is even harder to read than before since some of the lines are
> > now quoted and some are not.
> > 
> > >> 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!
> > 
> > It's hard to give any specific advice about fixing the unittest
> > failure without knowing what the test is testing. These two lines
> > don't seem to have anything to do with the algorithm that you quoted
> > in the first post, however:
> > 
> > >      numlist[i] = numlist[-1]
> > >      numlist = [1,2,3,4,5]
> > 
> > It looks like you should kill everything in this function after the
> > assignment to largest and then start reimplementing the algorithm
> > again from the " If Li is last number from  the list" step.
> 
> Thanks Ian!
> The algorithm is actually two part question, that's why the prime number part in the answer. And good enough that part isn't raising any errors.
> Still going over it hoping to get it right.
> Appreciate your input, God bless!

Hey did you manage to get the correct code? I've been stuck at this point for a week now!



More information about the Python-list mailing list