def display_inventory(inventory):
    """
    Formats and prints inventory shows details and quantities of each item

    :param dict inventory: inventory structure
    """
    output = 'Inventory:\n'
    total_items = 0

    for k, v in inventory.items():
        output += '{} {}\n'.format(v, k)
        total_items += int(v)

    return output + '\nTotal number of items: {}\n'.format(total_items)