class Employee:
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount = 1
def displayCount(self):
print ("Total Employee %d"% Employee.empCount)
def displayEmployee(self):
print ("Name : ", self.name, ", Salary: ", self.salary)
This is the block with the error
emp1 = Employee("Zara", 2000)
emp2 = Employee("Manni",5000)
emp1.displayEmployee()
emp2.displayEmployee()
print ("Total Employee %d" %Employee.empCount)
This is the error that shows up
Employee() does not take any input
CodePudding user response:
You have an indentation error. This is likely what you mean:
class Employee:
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount = 1
def displayCount(self):
print ("Total Employee %d"% Employee.empCount)
def displayEmployee(self):
print ("Name : ", self.name, ", Salary: ", self.salary)
CodePudding user response:
I think the problem is only related to the indentation of your code
class Employee:
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount = 1
def displayCount(self):
print ("Total Employee %d"% Employee.empCount)
def displayEmployee(self):
print ("Name : ", self.name, ", Salary: ", self.salary)
emp1 = Employee("Zara", 2000)
emp2 = Employee("Manni",5000)
emp1.displayEmployee()
emp2.displayEmployee()
print ("Total Employee %d" %Employee.empCount)