Cannot call class method

candidats is a list of names. You cannot retrieve a name (string) and use that directly to invoke a method of a user-defined class. You haven’t defined your purpose very well, but I suspect that what you want is for the class to hold a list of candidate objects. In this case, you’ll want something like:

def addCandidate(self, candidate):
    self.candidats.append(self, candidate)

Pass it the instance rather than the name.

Browse More Popular Posts

Leave a Comment