By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

class and instances: I wrote a program but that gives me an error.

P: 1
I wrote a simple program but it shows me an error:
#the program:
# Python classes

class Employee:

def __int__(self, first, last, pay):
self.__first = first
self.__last= last
self.__pay= pay
self.__email= first+ "." + last + ""

def fullname(self):
return '{} {}'.format(self.first, self.last)

def apply_raise(self): = int( * self.raise_amount)

a= Employee('Pawan' , 'Neu' , '555')
b= Employee('Sonu' , 'Khatri' , '666')

print (a.__dict__)

#the error is as follows:
Traceback (most recent call last):
File "C:\Users\user\Desktop\", line 19, in <module>
a= Employee('Pawan' , 'Neu' , '555')
TypeError: this constructor takes no arguments
May 22 '18 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 616
To be a member of the class, functions like __init__() have to be indented properly.
May 24 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.