0
Satchel = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1}
def displayInventory(inventory, leftWidth, rightWidth):
print('INVENTORY'.center(leftWidth + rightWidth, '-'))
for k, v in inventory.items():
print(k.ljust(leftWidth, '.') + str(v).rjust(rightWidth))
item_total = int(item_total) + int(v)
print('Total number of items: ' + str(item_total)
displayInventory(Satchel, 15, 6)
我在調用displayInventory函數時收到語法錯誤。我無法確定這段代碼有什麼問題。Python語法無效定義函數
什麼是確切的錯誤? –
請在將來更仔細地校對你的代碼。 – TigerhawkT3