Найти - Пользователи
Полная версия: SortedFreqs
Начало » Центр помощи » SortedFreqs
1
oxxxymiron
Это все тот же oxxxymiron со своими проблемами(
terabayt
def freqs(data):
    """
    return list of int values corresponding
    to frequencies of strings in data, a list
    of strings
    """
    if not data:
        return []
    r = [1]
    data.sort()
    for i in xrange(1, len(data)):
        if data[i] == data[i-1]:
            r[-1] += 1
        else:
            r.append(1)
    return r
data = ["apple", "pear", "cherry", "apple", "cherry", "pear", "apple", "banana"]
print freqs(data)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB