'''
Created on Sep 26, 2016

@author: Susan
This example processes words from a file 
by creating a list of all the words. 
'''
def lengthLongestWord2(words):
    allLengths = []
    for word in words:
        allLengths.append(len(word))
    return max(allLengths)

def lengthLongestWord3(words):  # This one is wrong
    return max(words)

def lengthLongestWord4(words):
    all = []
    for num in range(len(words)):
        all.append(len(words[num]))
    return max(all)
 


if __name__ == '__main__':
    datafile = "romeo.txt"
    #datafile = "small.txt"
    f = open(datafile)
    bigString = f.read()
    allwords = bigString.split()
    print "length of longest word"
    print lengthLongestWord2(allwords)
    print lengthLongestWord3(allwords)
    print lengthLongestWord4(allwords)

    

    
