Unwanted decimal in Python -


this question has answer here:

i have written code add values in tuple , calculate average:

def average(values):     return sum(values[0:]) / len(values[0:]) 

however, unwanted floating point, 2.0 instead of 2. how eliminate this, still manage correct average should average not integer?

you may try this:

if (yournumber).is_integer():         print int(n) else         print (n) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -