• Most wanted letter code question

Question related to mission The Most Wanted Letter

 

Hello All! I am new to this so I was wondering if someone could help me figure out why this code doesn't work on the website but works fine on my desktop and in a visualization for python that I use.

def checkio(text):
    letters = {}
    text = text.replace(' ', '')
    for l in str(text.lower()):
        if l in letters:
            letters[l] += 1
        else:
            letters[l] = 1
    x = sorted(letters)
    mx = max(x, key=letters.get)
    print (mx)
    return (mx)