Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

I know this isn't the place for functions but i am desperate ...Please Help!!

$
0
0
def hapax_legomena_ratio(text):
""" (list of str) -> float

Precondition: text is non-empty. Each str in text ends with \n and at
least one str in text contains more than just \n.

Return the hapax_legomena ratio for text. This ratio is the number of
words that occur exactly once divided by the total number of words.

>>> text = ['James Fennimore Cooper\n', 'Peter, Paul, and Mary\n',
'James Gosling\n']
>>> hapax_legomena_ratio(text)
0.7777777777777778
"""

Viewing all articles
Browse latest Browse all 2485

Trending Articles