Generate a python function that takes a list of strings and returns the longest one.
words = ['hello', 'world', 'this', 'is', 'a', 'test']
def longest_string(words):
    longest = 0
    result = ''
    for w in words:
        if len(w) > longest:
            longest = len(w)
            result = w
    return result