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
"""
""" (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
"""