0

I am trying to transcribe a sentence into a list of categories (one for each word in the sentence), but keep getting "AttributeError: 'NoneType' object has no attribute 'append'". Any ideas?

categories = {
    'direction':["north","south","east","west","down","up","left","right","back"],
    'verbs': ["go","stop","kill","eat"],
    'stop_words': ["the","in","of","from","at","it"],
    'nouns': ["door","bear","princess","cabinet"],
    'numbers': ["0","1","2","3","4","5","6","7","8","9"]
    }

sentence = "bear go left eat from cabinet 2."

words = sentence.split()

categorised_sentence = []

for word in words:
    print "---Looking at word:", word
    for category in categories.keys():

        if word in categories.get(category):
            print "===The category is:", category

            categorised_sentence = categorised_sentence.append(category)
            print "***categorised_sentence is: ", categorised_sentence
        else:
            print "hmm..."
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
ApRax
  • 7
  • 1
  • 5

0 Answers0