Я пытался распечатать свои объекты в виде списка. Список - это инвентарь. Его следует распечатать, набрав i. Но у меня только ошибка, которая показывает в списке объекты, которые нельзя распечатать. Я все время получаю ошибку. Пожалуйста, не могли бы вы мне помочь?
def play():
while True:
Action_input = get_player_action()
if Action_input in ["n","North"]:
print("Go North")
elif Action_input in ["s","South"]:
print("Go South")
elif Action_input in ["e","East"]:
print("Go East")
elif Action_input in ["w","West"]:
print("Go West")
elif Action_input in ["i","I"]:
print("Inventory")
for i in inventory:
print(inventory)
else:
print("Not an availble direction. Use only n,e,w,s,North,South,East, or West")
class Resources:
def __init__(self):
self.name = name
self.description = description
self.health = health
def __str__(self):
return " Name: " + self.name + "Description: " + str(self.description) + " Damage: " + str(self.damage)
class bread(Resources):
def __init__(self):
self.name = "bread"
self.description = "A kind of food that is cheap and nice."
self.health = 4
class pako(Resources):
def __init__(self):
self.name = "pako"
self.description = "A long piece of wood that can be used as a weapon"
self.damage = 10
class punch(Resources):
def __init__(self):
self.name = "punch"
self.description = "Using the fist to strike"
self.damage = 6
class owo(Resources):
def __init__(self):
self.name = "owo"
self.description = "What you use to buy goods or services"
self.value = 10
def get_player_action():
return input("What is your move?")
def best_attack_move(inventory):
Max_Attack = 0
Best_attack_move = None
for item in inventory:
if item.damage > Max_Attack:
Best_attack_move = item
Max_Attack = item.damage
return Best_attack_move
inventory = [bread(),pako(),punch(),owo()]
play()
Ошибка:
Каков ваш ход? I Inventory [<<strong> main .bread объект на 0x02ADC418>, <<strong> main .pako объект в 0x02ADC448>, <<strong> main .punch объект в 0x02ADC478>, <<strong> main объект .owo в 0x02ADC4A8>] [<<strong> main .bread объект в 0x02ADC418>, <<strong> main объект .pako в 0x02ADC448>, <<strong> main .punch объект в 0x02ADC478>, <<strong> main объект .owo в 0x02ADC4A8 >] [<<strong> main .bread объект в 0x02ADC418>, <<strong> main .pako объект в 0x02ADC448>, <<strong> main .punch объект в 0x02ADC478>, <<strong> main объект .owo в 0x02ADC4A8>] [<<strong> main .bread объект в 0x02ADC418>, <<strong> main объект .pako в 0x02ADC448>, <<strong> main .punch объект по адресу 0x02ADC478>, <<strong> main .owo объект по адресу 0x02ADC4A8>] Что вы делаете?