Python编程快速上手 AI Sweigart 5.6.2好玩的物品清单

stuff = {'rope': '3','torch': '6','gold coin': '111','dagger': '6'}

def displayInventory(inventory):
    print('Inventory:')
    item_total = 0
    for k,v in inventory.items():
        print(v + ' '+ k)
        item_total = item_total + int(v)
    print('Total numnber of items:' + str(item_total))

displayInventory(stuff)


版权声明:本文为m0_47572622原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。