# -------------------------------------------------------------------------------
# Name:        lecture8
# Purpose:     demonstrate the use of sets for counting unique items
#
# Author:      Rula Khayrallah
#-------------------------------------------------------------------------------
"""
Count the unique words in the Beatles song 'Yesterday'

"""
import string

def count_words(text):
    """
    count the unique words found in the string text

    Parameters: text, a string
    Returns: the number of unique words in text
    """
    text = text.lower()
    song_list = text.split()
    song_set = set()
    for i in song_list:
        song_set.add(i.strip(string.punctuation))
    #song_list = [i.strip(string.punctuation) for i in song_list]
    print(song_set)
    #song_list.pop('')
    #print(set(song_list))
    return len(song_set)
    # pass


def main():
    song = '''
        Yesterday, all my troubles seemed so far away
        Now it looks as though they're here to stay
        Oh, I believe in yesterday
        Suddenly, I'm not half the man I used to be
        There's a shadow hanging over me.
        Oh, yesterday came suddenly
        Why she had to go I don't know she wouldn't say
        I said something wrong, now I long for yesterday
        Yesterday, love was such an easy game to play
        Now I need a place to hide away
        Oh, I believe in yesterday
        Why she had to go I don't know she wouldn't say
        I said something wrong, now I long for yesterday
        Yesterday, love was such an easy game to play
        Now I need a place to hide away
        Oh, I believe in yesterday
        '''
    print(count_words(song))

if __name__ == '__main__':
    main()