# ACT2-3 functions.
# Remove the '#' characters as you write the functions below.

def readShel():
    '''Read in poem.txt and returns a list of words'''
    fileName = "poem.txt"
    myFile = open(fileName,"r")
    fileString = myFile.read()
    myFile.close()
    myList = fileString.split()
    return myList

def countWordsInShel():
    '''Returns the number of words in poem.txt'''
    myList = readShel()
    count = 0
    for word in myList:
        count = count + 1
    return count

def readMobyDick():
    '''Reads the text file MobyDick.txt and returns a list of words from the first 1000 characters'''
    fileName = 'MobyDick.txt'
    myFile = open(fileName,'r')
    fileString = myFile.read()
    myFile.close()
    print('Warning! Do not evaluate the entire list of MobyDick!')
    print('Returning the first 1,000 characters of the text.')
    fileString = fileString[0:1000]
    myList = fileString.split()
    return myList

def countWordsInMobyDick():
    '''Counts the number of words in MobyDick.txt'''
    myList = readMobyDick()
    count = 0
    for word in myList:
        count = count + 1
    return count 

#def avgWordLengthInMobyDick():
#    '''Gets the average word length in MobyDick.txt'''

#def getLongestWordInMobyDick():
#    '''Returns the longest word in MobyDick.txt'''

def vocabSize():
    '''Gets the vocabulary size of Moby Dick'''
    myList = readMobyDick()
    uniqueList = noReplicates(myList)
    return len(uniqueList)
    
#def noReplicates(wordList):
#    '''takes a list as argument, returns a list free of replicate items.
#    slow implementation.'''
        
#def isElementOf(myElement,myList):
#    '''takes a string and a list and returns True if the string is
#    in the list and False otherwise.'''

