input: Write a python function to calculate the average age for each name from a list of tuples.
  assert average_ages([("John", 20), ("Jacob", 18), ("John", 22), ("Jingleheimerschmidt", 15), ("John", 18)]) == [('John', 19.333333333333332), ('Jacob', 18.0), ('Jingleheimerschmidt', 15.0)]
  assert average_ages([("Alice", 30), ("Bob", 25), ("Alice", 35), ("Bob", 30)]) == [('Alice', 32.5), ('Bob', 27.5)]
  assert average_ages([("Tom", 40), ("Jerry", 10), ("Tom", 50), ("Jerry", 20)]) == [('Tom', 45.0), ('Jerry', 15.0)]
output: def average_ages(data):
      from collections import defaultdict
      age_sum = defaultdict(int)
      count = defaultdict(int)
      
      for name, age in data:
          age_sum[name] += age
          count[name] += 1
      
      return [(name, age_sum[name] / count[name]) for name in age_sum]