Light Mode
Dark Mode
Examples work but asserts do not

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))
Created: Dec. 8, 2018, 10:49 a.m.
Updated: Dec. 8, 2018, 11:08 p.m.
0
2
User avatar
pedroloruiz