Help me with this code

Dave Angel davea at davea.name
Wed Nov 6 06:44:21 CET 2013


On Tue, 5 Nov 2013 17:51:00 -0800 (PST), chovdary at gmail.com wrote:
>         result  +=  ((-1) ** (k+1))/2*k-1

One of two things are happening here. Maybe both.

You're using Python 2.x (and should havesaid so) where integer 
division is truncated.

You're missing around some part of the intended denominator. Check 
operator precedence rules.

-- 
DaveA




More information about the Python-list mailing list