def vocab(filename):
    '''takes a filename as argument, returns the list that contains the
    vocaublary of that file.'''
    myString = readFile(filename)
    myWords = myString.split()
    reducedMyWords = noReplicates(myWords)
    return reducedMyWords

def readFile(filename):
    '''takes a filename as argument, returns a string that contains
    the first 10000 characters in that file.'''
    myFile = open('Z:/WinData/Desktop/' + filename)
    myString = myFile.read()
    return myString[:10000]

def noReplicates(wordList):
    '''takes a list as argument, returns a list free of replicate items.
    slow implementation.'''
    result = []
    for word in wordList:
        if isElementOf(word, result):
            pass
        else:
            result += [word]
    return result
        

def isElementOf(a,l):
    '''takes two arguments, second being a list.
    returns True if the first arg is an element of the second,
    returns False otherwise.'''
    for item in l:
        if a == item:
            return True
    return False

# Two ways of iterating through a list
# The first one gives you extra powers
wordList = ['steve jobs', 'apple', 'ipod', 'ipad', 'iphone 4s']

print('New way of interating...')
for index in range(0,len(wordList)):
    if index == 0:
        print(wordList[index] + ' comes after nothing.')
    else:
        print(wordList[index] + ' comes after ' + wordList[index-1] + '.')

print('\nOld way...')
for word in wordList:
    print(word)


##########################################################################
#########################  ACTUAL HOMEWORK  ##############################
##########################################################################


def fastNoReplicates(wordList):
    '''takes a list as argument, returns a list free of replicate items.
    fast implementation.'''
    result = []
    wordList.sort() # Here wordList is sorted. Nothing is returned by sort() but wordList is changed

    #TODO
    

    return []   # dummy value to return



def cleanup(s):
    '''takes a string as argument, and returns a cleaned-up string,
    free of numbers and punctuations, all lowercase.'''
    result = s.lower()
    result = removeNumbers(result)
    result = removePunctuations(result)
    return result


def removeNumbers(s):
    '''takes a string as argument, and returns another string,
    replacing numbers with whitespaces.'''
    result =''
    for char in s:
        if(char=='0' or char=='1' or char=='2' or char=='3'
           or char=='4' or char=='5' or char=='6' or char=='7'
           or char=='8' or char=='9'):
            result += ' '
        else:
            result += char
            
    return result
            

def removePunctuations(s):
    '''takes a string as argument, and returns another string,
    replacing numbers with whitespaces.'''
    #TODO

    return s   # dummy value to return




















