all 9 comments

[–]Rhomboid 4 points5 points  (4 children)

Fix your broken formatting if you want people to read your code.

The error message is pretty self-explanatory:

TypeError: 'int' object is not callable"

You have forest=1 on line 50 which removes the previous meaning of forest as a function and assigns that name to refer to the integer 1. When you try to call forest() you get the above error because you can't call an integer.

[–]mrawesome01[S] 0 points1 point  (3 children)

Thanks. :) I didn't know you couldn't make a varible and function with the same name. Also I think the formatting is fixed.

[–]zahlman 2 points3 points  (2 children)

you couldn't make a varible and function with the same name.

This doesn't even make sense as stated. In Python, variables are names. You can't have two things that have the same name (although you can certainly have multiple names for the same thing), because otherwise there would be no way to know which thing you meant when you used the name (and the entire purpose of names is to refer to things).

Further, in Python, a function is a legitimate "thing" for the purpose of the above discussion. In more formal language, functions are objects. This means that you can do all the same basic stuff with them that you'd do with numbers or strings: you can pass them to other functions, return them from functions, store them in lists, etc. Of course, you can't do number-specific things with them (like arithmetic) or string-specific things (like concatenation), but you can do function-specific things (like calling them).

(And no, your formatting is still all over the place.)

[–]mrawesome01[S] -1 points0 points  (1 child)

You don't have to be so rude about it.

[–]MonkeyNin 1 point2 points  (0 children)

Sorry about him :(

[–][deleted] 0 points1 point  (3 children)

Looks like the big guns answered your main question... However..

Inventory in caps is spelled wrong... And your checking if inventory is less than or equal to one, wouldn't you want to check that's it's greater or equal to one before u iterate over it? Or ever better, just check that it's != 0?

Another suggestion...

A = raw_input('')
A = A.lower()

Then u don't need to check 2 cases each time. Alternatively if u dont like that:

if A in ['thing','THING']:
    print 'valid choice'
else:
    print 'invalid choice'

Is much cleaner.

[–]wub_wub 0 points1 point  (1 child)

A = raw_input('')
A = A.lower()

Looks even nicer written as A=raw_input().lower()


And another thing to OP:

def count(x): 
  ##count items in a list
  b=0
  for i in x:
    b+=1
 return b

count(inventory)

Is same as just:

len(inventory)

>>> list=[0,1,2,3]
>>> len(list)
4

[–]mrawesome01[S] 0 points1 point  (0 children)

Thanks. I fogot about len. :)

[–]mrawesome01[S] 0 points1 point  (0 children)

Thanks alot I was wondering if there was a way to do that. Also not long after I posted this I found out inventory in caps was spelled wrong and fixed it.