displayInventory

# Write a function named displayInventory() that would take any possible “inventory” and display it like the following:

    Inventory:

12 arrow
42 gold coin
1 rope
6 torch
1 dagger
Total number of items: 62  

def displayInventory(dic_name):
    print('INVENTORY'.center(25,'-'))
    sum_total=0
    for k,v in dic_name.items():
        print(str(v).ljust(10,'.')+str(k).rjust(15,' '))
        sum_total=sum_total+int(v)
    print('Total number of items: '+str(sum_total))

 

 
posted on 2017-08-25 23:16  auleon  阅读(210)  评论(0编辑  收藏  举报