Nonetype object has no attribute 'items' when looping through a dictionary
<p>I have two dictionaries, one represents a player inventory and the other represents a dragon inventory. I'm trying to take the two dictionaries and combine them. Then display those two dictionaries as the player's new inventory. I have added my code below and I keep getting the following error.</p>

<pre><code>Traceback (most recent call last):
  File "/Users/DakotaDickey/Documents/Python Projects /Examples/FantasyGameAddToInventory.py", line 38, in &lt;module&gt;
    displayInventory(inv)
  File "/Users/DakotaDickey/Documents/Python Projects /Examples/FantasyGameAddToInventory.py", line 27, in displayInventory
    for k, v  in inventory.items():
AttributeError: 'NoneType' object has no attribute 'items'
</code></pre>

<p>my code:</p>

<pre><code>#FantasyGameAddToInventory


def addToInventory(inventory, addedItems):
    addedItemsdict = {} 
    for item in addedItems:
        x = addedItems.count(item)
        if item not in addedItemsdict:
            addedItemsdict[item] = 1
        else:
            addedItemsdict[item] = x

    for k, v in addedItemsdict.items():
        if k in inventory:
            x = inventory[k]
            inventory[k] = v + x
        else:
            inventory[k] = v
    inv = inventory           
    print(inv)

def displayInventory(inventory):
    print('Inventory:')
    item_total = 0

    for k, v  in inventory.items():
        print(k,v)
        item_total = item_total + v



    print("Total number of items: " + str(item_total))

inv = {'gold coin' : 42 , 'rope': 1}
dragonLoot = ['gold coin', 'dagger' , 'gold coin', 'gold coin', 'ruby']
inv = addToInventory(inv, dragonLoot)
displayInventory(inv)
</code></pre>

<p>The output Im trying to produce is as follows. 
Inventory:</p>

<p>45 gold coin</p>

<p>1 rope</p>

<p>1 ruby</p>

<p>1 dagger</p>

<p>Total number of items: 48</p>