Ask coding questions

← Back to all posts
What goes wrong?
BearCoder01 (8)

I got an error on line 104. When you buy nothing (buy the table) you get an error TypeError: 'int' object is not subscriptable. What can I do?. Please help.

Coder100 (18200)

Here is why

if you haven't realized, you overrode the global items variable with your own variable that was part of the original items array, so rename that items variable.

OldWizard209 (1539)

Yeah this happens when u try to access an integer as if it were a subscribable object, like a list. Take a look here to solve the issue.
I would've helped you but your code is long so I didnt bother. Sorry

BearCoder01 (8)

@OldWizard209 This only happens only is you bought (a table) in the first part of the code (`printBuyItems()) there is an error, but if you doesn't buy something (hit the [ETNTER] then there isn't an error.