Append result of variable to a list

Question!

I am trying to add the result of a variable f to the end of a list list_name. However, when I try to do this I get the following error:

list_name.append[f]  

TypeError: 'builtin_function_or_method' object is not subscriptable

What am I doing wrong?

By : Eden Crow


Answers
append is a method (function) so you should call it with simple parentheses.

And of course, a function is not subscriptable, so you get an error...

(An object is subscriptable when it has a __getitem__ method.)



This video can help you solving your question :)
By: admin