inventory = {
'gold' : 500,
'sack' : ['rock', 'copper wire'],
'weapons rack' : ['pistol', 'MP-5', 'grenade'],
'ammo pouch' : ['Pistol ammo', 'MP-5 ammo'],
}
print "You have " + inventory['gold'][0] + " coins!"
Я получаю сообщение об ошибке:Кодирование в Python, команда печати не действует, как ожидалось
line 8, in <module>
print "You have " + inventory['gold'] + " coins!"
TypeError: 'int' object has no attribute '__getitem__'
почему бы не консоль распечатывают "You have 500 gold coins!"