transforming wordnet txt into lists in python nltk
Question: **I am running the following function:**

    
    
    import nltk
    from nltk.corpus import wordnet as wn
    
    def noun_names(list): 
        for synset in list:
            for lemma in synset.lemmas():
                print lemma.name()
    
    noun_names(list(wn.all_synsets(wn.NOUN)))
    

**and it returns a long list of all the names of nouns in wordnet:**

e.g.

    
    
    epoch
    Caliphate
    Christian_era
    Common_era
    day
    year_of_grace
    Y2K
    generation
    anniversary
    

How do I take this output, which is neither a string or a list, and turn it
into a list? Thanks so much.


Answer: Instead of printing to the stdout with your:

    
    
    print lemma.name()
    

Why not append it to a list and return the list?

    
    
    def noun_names(list):
        names = []
        for synset in list:
            for lemma in synset.lemmas():
                names.append(lemma.name())
        return names
    
    names = noun_names(list(wn.all_synsets(wn.NOUN)))
    

