Why I can not add a word into the empty list?

When I wanted to append a word item into an empty list

It always gave me an error and not working.

list_name = [ ]
list_name.append(item)

then you might need to:
list_name = np.asarray(list_name)

If you post your code, it’ll be easier to help out.

image

Just not sure why this word did not add into the empty list. It is in the Vocabulary.

1 Like

What’s happening is that you’re setting the list equal to None with =, because the method/function list.append() doesn’t return a value (it modifies the list “in-place”). So what you need to do is just suggestions.append(word) without the suggestions = part.

Thank you So much!!!