def higher(text): text = text.replace(" ", "") count = 0 for char in text: current_count = text.count(char) if current_count > count: count = current_count last = char return text.replace(last, "") print(higher("uk aaaa aaaa eeee iiii eeee iiii ku")) print(higher("otro texto")) // varias veces el mismo texto print(higher(higher("uk aaaa aaaa eeee iiii eeee iiii ku"))) print(higher(higher(higher("uk aaaa aaaa eeee iiii eeee iiii ku"))))