The inventory parameter is a dictionary representing the player’s inventory and the addedItems parameter is a list. The addToInventory() function should return a dictionary that represents the updated inventory.The program should output the following:

```
Inventory:

45 gold coin
1 rope
1 ruby
1 dagger

Total number of items: 48

```

Here's my code:

```
def addToInventory(inventory, addedItems):
    print('Inventory:')
    totalItem = 0
    for i in range(len(addedItems)):
        if addedItems[i] in inventory:
        inventory[str(addedItems[i])] += 1
    if addedItems[i] not in inventory:
        inventory[str(addedItems[i])] = 1
    for k, v in inventory.items():
        print(str(v) + ' ' + k)
        totalItem += int(v)

    print('Total number of items:' + str(totalItem))

inv = {'gold coin':42,'rope':1}
dragonLoot = ['gold coin','dagger','gold coin','gold coin','ruby']
inv = addToInventory(inv,dragonLoot)

```

I was wondering how to work on the for loop bit. It seems strange to me now (and way too long). Thx!