Q:

How to condense this function?

def average(tup):
  """ ugiufh """
   total = ((int(tup[0]) + int(tup[1]) + int(tup[2]))/3,
            (int(tup[0]) + int(tup[1]) + int(tup[2]))/3,
            (int(tup[0]) + int(tup[1]) + int(tup[2]))/3)
   return total

I am writing a function to average out three element in a tuple which means if the original tuple = (1, 2, 3) which give me tuple = (2, 2, 2)
My question is there any way to condense what wrote to give me the same answer? If yes, how to condense it?
Thanks

A:

If you are sure you want integer division, you can use
def average(tup):
    n = len(tup)
    return (sum(int(x) for x in tup) / n,) * n

