Source code
class Contact:
def __init__(self, first_name, last_name):
self.first_name = first_name
self.last_name = last_name
self.full_info = first_name + " " + last_name
def print_contact(self):
print(self.full_info)
class EmailContact(Contact):
def __init__(self, first_name, last_name, email):
super.__init__(first_name, last_name)
self.email = email
self.full_info = email
email_contact = EmailContact("test","person","test@person.com")
Problem and correct
In this case, this problem is related to mistype of calling super class, it should be super().super.__init__(first_name, last_name) but not super.__init__(first_name, last_name) :
class Contact:
def __init__(self, first_name, last_name):
self.first_name = first_name # use self to create property
self.last_name = last_name
self.full_info = first_name + " " + last_name
def print_contact(self):
print(self.full_info)
class EmailContact(Contact):
def __init__(self, first_name, last_name, email):
super().__init__(first_name, last_name)
self.email = email
self.full_info = email
No comments :
Post a Comment