so i have this little program
Code:
class MyTodos:
def __init__(self):
self.list = []
def add(self, todo):
self.list.append(todo)
def filter(self, s):
l = []
for i in self.list:
if i.find(s) != -1:
l.append(i)
return l
todos = MyTodos()
todos.add("prepare fp").add("learn python").add("learn JS")
for todo in todos.filter("learn"):
print(todo)
and i get this error:
Code:
todos.add("prepare fp").add("learn python").add("learn JS")
AttributeError: 'NoneType' object has no attribute 'add'
how can i fix it? i don't understand why after performing this:
Code:
todos.add("prepare fp")
todos becomes a NoneType
Bookmarks