Whenever I run this code I always get a TypeError
that says __init__() missing 1 required positional argument: 'hours'
,
but I am not trying to change anything from the original class that the ScientificSwimmer
class is inheriting from…if that makes sense.
Here is the code:
class Human:
def __init__(self, name, age):
self.name = name
self.age = age
def hobby(self):
print("Likes watching Netflix")
def info(self):
print(self.name , "is ",self.age," years old")
class Scientist(Human):
def __init__(self, name, age, lab):
super().__init__(name, age)
self.lab = lab
def hobby(self):
print("Likes doing scientific experiments")
def labName(self,lab):
print("works at the " ,lab, "laboratory")
class Swimmer(Human):
def __init__(self, name, age, hours):
super().__init__(name,age)
self.hours = hours
def hobby(self):
print("likes swimmming in the lake" )
def hoursSwimming(self, hours):
print("swims ", hours , "hours per week")
class ScientificSwimmer(Scientist, Swimmer):
def __init__ (self, name, age, lab, hours):
Scientist.__init__(self,name, age, lab)
Swimmer.__init__(self, name, age, hours)
scienswim = ScientificSwimmer("\nJohn Smith", 30, "nuclear", 100)
scienswim.info()
scienswim.hobby()
scienswim.labName("nuclear")
scienswim.hoursSwimming(100)
My desired result is for it to print:
John smith is 30 years old.
likes doing scientific experiments.
works at the nuclear laboratory.
swims 100 hours per week.