• Register
+2 votes
6 views

Problem:

I was working on a project where I was trying to implement a subclass. The code I wrote for that was:
class OverViewOfWork(Utilities.Utility):
    def TotalHourWorked():
        pass    
    def DaysWorked():
        pass
    def AvarageWorks():
        pass
    def Salary():
        pass  

But it throws some error like:

TypeError: TotalHourWorked() takes 0 positional arguments but 1 was given
TypeError: DaysWorked() takes 0 positional arguments but 1 was given
TypeError: AvarageWorks() takes 0 positional arguments but 1 was given
TypeError: Salary() takes 0 positional arguments but 1 was given

What is the problem here?

ago by (2.6k points)  

1 Answer

+2 votes

Answer:

In your code you need add a parameter which is called 

self

to all of your function in the class OverViewOfWork

So write your code like:

class OverViewOfWork(Utilities.Utility):
    def TotalHourWorked(self):
        pass    
    def DaysWorked(self):
        pass
    def AvarageWorks(self):
        pass
    def Salary(self):
        pass  

Let me know if it is working for you or not. Happy coding.

ago by (4.5k points)  
...