You probably know that the "mode" of a set of data is the data point that appears most frequently. Looking at the characters that make up the string `"sarsaparilla"` we can see that the letter `"a"` appears four times, more than any other letter, so the mode of `"sarsaparilla"` is `"a"`.

But do you know what happens when two or more data points occur the most? For example, what is the mode of the letters in `"tomato"`? Both `"t"` and `"o"` seem to be tied for appearing most frequently.

Turns out that a set of data can, in fact, have multiple modes, so `"tomato"` has two modes: `"t"` and `"o"`. It's important to note, though, that if *all* data appears the same number of times there is no mode. So `"cat"`, `"redder"`, and `[1, 2, 3, 4, 5]` do not have a mode.

Your job is to write a function `modes()` that will accept one argument `data` that is a sequence like a string or a list of numbers and return a sorted list containing the mode(s) of the input sequence. If data does not contain a mode you should return an empty list.

For example:

```python
>>> modes("tomato")
["o", "t"]
>>> modes([1, 3, 3, 7])
[3]
>>> modes(["redder"])
[]
```

You can trust that your input data will always be a sequence and will always contain orderable types (no inputs like `[1, 2, 2, "a", "b", "b"]`).

Difficulty: EASY
Starter code: def modes(data):
	

Solutions:
from collections import Counter

def modes(data):
	cnts = Counter(data)
	(mx, mn) = (max(cnts.values()), min(cnts.values()))
	return sorted([k for k in cnts if cnts[k] == mx and cnts[k] != mn])


def modes(data):
	frequency = {}
	mode_list = []
	for d in data:
		if d in frequency:
			frequency[d] += 1
		else:
			frequency[d] = 1
	for f in frequency:
		if frequency[f] == max(frequency.values()) > min(frequency.values()):
			mode_list.append(f)
	return sorted(mode_list)


def modes(data):
	d = {i: data.count(i) for i in set(data)}
	return [] if len(set(d.values())) == 1 else sorted([i for i in set(data) if d[i] == max(d.values())])


from collections import Counter

def modes(data):
	c = Counter(data)
	m = max(c.values())
	if min(c.values()) == m:
		return []
	return [key for key in sorted(c) if c[key] == m]


from collections import Counter

def modes(data):
	result = []
	counts = Counter(data)
	if len(set(counts.values())) > 1:
		result += sorted((k for (k, v) in list(counts.items()) if v == max(counts.values())))
	return result


from collections import Counter

def modes(data):
	count = Counter(data)
	m = max(count.values()) if len(set(count.values())) > 1 else 0
	return sorted((item for (item, number) in count.items() if 0 < m == number))


def modes(data):
	dict = {i: data.count(i) for i in data}
	if max(dict.values()) != min(dict.values()):
		return sorted([key for (key, value) in dict.items() if value == max(dict.values())])
	return []


def modes(data):
	(most, l, length) = (0, [], len(data))
	for x in set(data):
		res = data.count(x)
		if most < res:
			most = res
			l = []
			l.append(x)
			length = len(data) - most
		elif most == res:
			l.append(x)
			length -= most
	return sorted(l) if length else []


def modes(data):
	d = {}
	for i in set(data):
		d[data.count(i)] = d.get(data.count(i), []) + [i]
	if len(d) == 1:
		return []
	else:
		return sorted(d[max(d.keys())])


def modes(data):
	counts = {}
	for value in data:
		if value in counts:
			counts[value] += 1
		else:
			counts[value] = 1
	max_occurrence = max(counts.values())
	min_occurrence = min(counts.values())
	if max_occurrence == min_occurrence:
		return []
	result = []
	for key in counts.keys():
		if counts[key] == max_occurrence:
			result.append(key)
	return sorted(result)