-1
 def filter_list_by_value(self):
        self.get_user_input("Insert number to filter by: ")
        value = int(self.__user_input)
        print(value)
        new_list = list()
        try:
            self.history_stack.append(str(self.expense_list))
            for item in self.expense_list:
                try:
                    new_list.append(list(filter(lambda val: val > value, item.expense)))
                except TypeError as te:
                    print("type error" , te)
            self.expense_list = new_list
        except TypeError as te:
            print("Type error!", te)

class Expense: def init(self, expense: int, category: str, day: int): self.__expense = expense self.__category = category self.__day = day

def __repr__(self):
    return str(self)


def __str__(self):
    return str(self.__dict__)


@property
def day(self):
    return self.__day

@day.setter
def day(self, day):
    self.__day = day

@property
def expense(self):
    return self.__expense

@expense.setter
def expense(self, expense):
    self.__expense = expense

@property
def category(self):
    return self.__category

@category.setter
def category(self, category):
    self.__category = category

I keep getting 'int' object is not iterable. What should I do? expense_list is an class-made object.

manati1
  • 37
  • 5

1 Answers1

0

Judging by:

new_list = list()
...
new_list.append(list(...))
...
self.expense_list = new_list

self.expense_list has to be a list of lists. However, by:

for item in self.expense_list:
    ...
    item.expense

It cannot be, since lists don't have an expense attribute. Please verify you have all your datatypes straight.

Gloweye
  • 1,294
  • 10
  • 20
  • Well i thought I could call the expense getter from the repo. class Expense: def __init__(self, expense: int, category: str, day: int): self.__expense = expense self.__category = category self.__day = day def __str__(self): return str(self.__dict__) [at]property def expense(self): return self.__expense [at]expense.setter def expense(self, expense): self.__expense = expense – manati1 Nov 15 '19 at 19:47
  • Could you edit that into your question? That's useful information. Along with any other ways expense_list can be constructed. Because this code looks like several errors competing to come first. – Gloweye Nov 16 '19 at 08:36