def create_spend_chart(categories: list) -> str:
    """
    Takes a list of categories as argument and return a bar chart.

    :categories: list of categories (instances from `Category`) -> list
    :returns: bar chart -> str
    """
    msg = 'Percentage spent by category\n'

    # calc total spents in each category and the 
    # total spents in `categories` list
    totals = 0
    cat_total = dict()
    max_word_size = 0
    for category in categories:
        ledger = category.ledger
        name = category.category
        word_size = len(name)
        if word_size > max_word_size:
            max_word_size = word_size
        cat_total[name] = 0
        for item in ledger:
            amount = item['amount']
            if amount < 0:
                cat_total[name] += amount
        totals += cat_total[name]

    # calc percentages
    cat_percentage = dict()
    for category, amount in cat_total.items():
        percentage = 100 * (amount / totals)
        integer = round(percentage)
        nearest = 10 * (integer // 10)
        cat_percentage[category] = nearest

    # print axis
    for i in range(100, -1, -10):
        msg += f'{i:>3}| '
        for value in cat_percentage.values():
            if value < i:
                msg += '   '
            else:
                msg += 'o  '
        msg += '\n'

    # print separator
    width = len(categories) * 3
    msg += '    -' + '-' * width + '\n'

    # print labels
    for i in range(0, max_word_size):
        msg += '     '
        for category in categories:
            name = category.category
            try:
                msg += f'{name[i]}  '
            except:
                msg += f'   '
        if i < max_word_size - 1:
            msg += '\n'

    return msg