我有一本这样的字典:
inventory = {'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone'],
'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']}
我怎样才能从中取出匕首?
我试过这个:
inventory["backpack"][1].remove()
或者
del inventory["backpack"][1]
但它犯了这个错误:
Traceback (most recent call last):
File "python", line 15, in <module>
TypeError: 'NoneType' object has no attribute '__getitem__'