Hey all,

Can someone help me reduce this code?  It sure seems
like there ought to be a way to loop this or combine
things so that there is only 1 or 3 lines to this
instead of 6.  I've been scratching my head over this
for a while though I can't come up with anything.
Just as a note, I need even_odd_round left alone because
it is not always used.  I just included for clarity.

As always, thanks in advance,

Lance

T2B = even_odd_round(float(str(T2B)))   
VS  = even_odd_round(float(str(VS)))    
SS  = even_odd_round(float(str(SS)))    
sh.Cells(21,lastcol+1).Value = float(str(T2B))/100
sh.Cells(22,lastcol+1).Value = float(str(VS))/100
sh.Cells(23,lastcol+1).Value = float(str(SS))/100



def even_odd_round(num):
        if(round(num,2) + .5 == int(round(num,2)) + 1):
                if num > .5:
                     if(int(num) % 2):
                        num = round(num,2) + .1 #an odd number
                     else:
                        num = round(num,2) - .1 #an even number
                else:
                   num = 1
        rounded_num = int(round(num,0))
        return rounded_num
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to