Listing contents of a list containing class objects not working properly

3063 views python

I have a class task that contains information of a task and a method to expand it as follows:

#define class for tasks
class task:
    def __init__(self, name, date, category): = name = date
        self.category = category
    def expand(self): # returns the contents of the task
        print(str( + " is due " + str(

and a function listTasks() that lists the contents of a standard list that contains objects of the class task as follows:

def listTasks():
    i = 1
    for task in data:
        print("%s. %s" % (i, task.expand()))
        i = i+1

The idea is for the listTasks function to display a coherent list that looks like

1. Foo is due tomorrow
2. Foobar is due in 2 days
3. FooFoo is due in five years

etc.. but the actual output looks as follows:

foo is due tomorrow
1. None
foobar is due in 2 days
2. None

Can anyone help me understand why?

answered question
Add a Comment

0 Answer

Please login first before posting an answer.