"masawudu bature" <mass0...@yahoo.ca> wrote

The output is suppose to count the number of even divisors the range has.

You need to work this through again in your head:

def evenCount(b) :

This function takes a parameter b but you never use b in the function...

   for n in range(x, y+1) :

What are x and y supposed to be? They must be defined
outside the function? Don;t you really want your loop to check
the values for b? So it would be range(0,b+1)?

       count = 0

You reset count to zero for each time through the loop - do
you really want to do that?

       if n % 2 == 0 :
           count += n/3

Why do you add n/3?

           count % n == 1

This is a boolean expression that will evaluate to TRue or False
and which you then ignore. It does nothing useful.

       return n

And this will always return the first value of your loop, x.

Try working through it on paper, writing down the values of each variable in the function for each time through the loop. Are they what you expect?

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to