Reputation: 43
Im trying to test out some stuff so I can make a python text adventure, but its not working. Here is the code:
calories = [3]
fooland= ("fooland")
area=fooland
joint= ("joint")
while area=="fooland":
talk=raw_input("Where to go?")
if talk==joint:
area=joint
else:
print "You cant do that!"
while area=="joint":
order=raw_input("What to order?")
if order=="fries":
print "You eat like a BAWS"
calories.append[2]
else:
print "You cant eat that, but here is some grease!"
calories.append[6]
if [calories < 10]:
print "YOU ARE FAT"
But i get this error:
'builtin_function_or_method' object has no attribute '__getitem__'
What am i doing wrong and how can i fix it?
Upvotes: 3
Views: 24907
Reputation: 81
I also met this problem ever, and I found that the reason is that I wrote []
after function invoke wrongly:
f.pop[para1] // wrong
f.pop(para1) // correct
Just change []
into ()
and program can work.
Upvotes: 1
Reputation: 1
You have to do:
if (int(calories) < 10):
print "YOU ARE FAT"
Upvotes: 0
Reputation: 49805
To call a method (like append
), you wrap the parameters in () not [].
Upvotes: 4