• Examples work but asserts do not

Question related to mission The Most Wanted Letter

 

This code seems to return the correct answer, but the asserts return an error. What am I doing wrong?

import re

def checkio(x):
  count = {}
  x = str.lower(x)
  x = re.sub("[^a-z]+", "", x)

  for character in x:
    count.setdefault(character, 0)
    count[character] = count[character] + 1
  final = list(count.values())
  if all(x == final[0] for x in final):  
      firstAlpha = list(count.keys())
      firstAlpha.sort()
      print(firstAlpha[0])
  else:
      print(max(count, key=count.get))