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
Post a Comment