• Using min(a,b) won't work?

Question related to mission The Most Wanted Letter

For this, I used, as way to determine the correct letter to return, the following snippet when I had two letters that appeared the same number of times:

elif text.count(x) == total:

              if x < letter:
                    letter = x

because using min(letter,x) was not working in here; but did locally. Why could this happen?


this is the solution that is not working in here but does locally (running pyCharm):

from string import *

def checkio(text):
    total, letter = 0, 'z'
    text = text.lower()
    for x in set(text):
        if x not in ascii_lowercase:
        if text.count(x) > total:
            letter = x
            total = text.count(x)
        elif text.count(x) == total:
    return letter