def invert(t): return max(t.split(' '), key=lambda x: t.lower().count(x))
>>> import collections >>> >>> def f(s): ... counted = collections.Counter(map(str.lower, s.split())) ... out = counted.most_common(1)[0][0] ... return out ... >>> f('abc DEF ghi ABC hij') 'abc' >>>
>>> def f(s): ... dct = {} ... for i in map(str.lower, s.split()): ... dct[i] = dct.get(i, 0) + 1 ... out = max(dct.items(), key=lambda i: i[1])[0] ... return out ... >>> f('abc DEF ghi ABC hij') 'abc' >>>