TypeError: 'list' object is not callable while trying to access a list TypeError: 'list' object is not callable while trying to access a list python python

TypeError: 'list' object is not callable while trying to access a list


For accessing the elements of a list you need to use the square brackets ([]) and not the parenthesis (()).

Instead of:

print  wordlists(len(words))

you need to use:

print worldlists[len(words)]

And instead of:

(wordlists(len(words))).append(words)

you need to use:

worldlists[len(words)].append(words)


To get elements of a list you have to use list[i] instead of list(i).


wordlists is not a function, it is a list. You need the bracket subscript

print  wordlists[len(words)]