def term_frequency(text, word):
    """Takes in a text (list of strings) and calculates
    TF(t) = (number of times term appears in text) / (total number of terms in a text)"""
    total_words = len(text)
    word_in_text = text.count(word)
    try:
        return float(word_in_text) / float(total_words)
    except ZeroDivisionError:
        return 0