Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Store Sys

I've tried to create a store system which I think would work good except that my function gets an error. (The function is called store and it's at the end of the file)

My code: https://w.trhou.se/j2gevv32wy (Look at the end for the store function)

Whenever I try to buy an item from the weapon I get this error:

TypeError: 'builtin_function_or_method' object is not subscriptable

I don't really know what that means so i'm asking you, treehouse community what the problem is.

1 Answer

Steven Parker
Steven Parker
243,318 Points

Instead of subscripting the built-in append function:

            PlayerIG.weap.append[option]

:point_right: You probably want to invoke it and pass an argument:

            PlayerIG.weap.append(option)

(parentheses vs. brackets)

Also, it would seem more intuitive to select the item by number, as with the other inputs.