[Tutor] Doing the same thing twice. Works first time but not the second.
Matthew Love
matthewlove94 at googlemail.com
Fri Aug 17 22:11:34 CEST 2012
This error is confusing me. I am wondering if anyone can help me out.
Using W7 64 Ultimate
Using Python 3.1.1
This is the relevant part of the program.
class Player(object):
def __init__(self):
print("Player created.")
def inventory(self):
self.inventory = ["torch"]
return self.inventory
player = Player()
print("\nYour current inventory is", end= " ")
print(player.inventory())
print("\nYour current inventory is", end= " ")
print(player.inventory())
The first time the program prints the inventory correctly but when it
does the exact same thing again it throws up an error. I can't think
of a reason for why this happens.
This is the error:
Traceback (most recent call last):
File "C:\Users\Matthew\Desktop\test.py", line 16, in <module>
print(player.inventory())
TypeError: 'list' object is not callable
Can anyone help me with this? I'd appreciate it.
More information about the Tutor
mailing list