Python - Budget app

Hello guys, it has been some days since my last post here.

I am currently working on the budget app project. I was very confused with the concept and syntax around classes in python so I decided to search for tutorials to check how the syntax works in this project specifically (before that I read the python official documentation). Having checked that, I stopped the video (because I wanna be able to solve it on my on) and now I am trying to set the way that the category class is going to be printed.

I am running into some issues with how to get the description and amount from the ledger and put them in a new variable: Here is how my code looks:

    def __repr__(self):

        n = int((30 - len(       
        num_asterisks = '*' * n    
        Headline ='\n'

        for i in self.ledger:
            description_index = i.index(description)
            transaction = i[description_index:]

I know I need a For loop to check each index of the self.ledger. But I don’t know how to access the description and the amount.

Thanks to all in advance

This might be better if you posted it in the Python category:

But I personally would have to see more of your code to help you. I’m not entirely sure how your ledger is formatted or how you’re using the .index method.

Try printing what exactly is the i when you are iterating over self.ledger. This will show better what can be done with it later.

1 Like