peztherez
peztherez

Reputation: 4001

python list append gives a error: AttributeError: 'function' object has no attribute 'append'

I have list = [] and I am adding an element to it using self.list.append('test') and I get this error - AttributeError: 'function' object has no attribute 'append'

The other list that I have defined append just fine, any ideas?

Upvotes: 5

Views: 21888

Answers (2)

Kanishka Gupta
Kanishka Gupta

Reputation: 11

first of all,you cannot use in-built function 'list' as a variable name and second is that with function object we cannot use append

Upvotes: 1

Saullo G. P. Castro
Saullo G. P. Castro

Reputation: 58895

It seems you have a function in your code that is shadowing Python's built-in function named list.

Upvotes: 10

Related Questions