code: def vote_mean(candidates, votes, n_winners):
      sums = {str(candidate): [] for candidate in candidates}
      for vote in votes:
          for v in vote:
              sums[str(v[0])].append(v[1])
      for s in sums:
          sums[s] = sum(sums[s]) / len(sums[s])
      ordering = list(sums.items())
      ordering.sort(key=operator.itemgetter(1), reverse=True)
      best = ordering[:min(n_winners, len(ordering))]
      d = []
      for e in best:
          for c in candidates:
              if str(c) == e[0]:
                  d.append((c, e[1]))
      return d