My issue
return "This magical creature " + ", ".join(a) + “.”
My code
class Dragon:
def __init__(self):
self.can_fly = True
self.breathes_fire = True
class Unicorn:
def __init__(self):
self.has_horn = True
self.grants_wishes = True
class Mermaid:
def __init__(self):
self.swims_fast = True
self.sings_beautifully = True
class HybridCreature(Dragon,Unicorn,Mermaid):
def __init__(self):
Dragon.__init__(self)
Unicorn.__init__(self)
Mermaid.__init__(self)
def describe_abilities(self):
a=[]
if self.can_fly:
a.append("can fly")
if self.breathes_fire:
a.append("breathes fire")
if self.has_horn:
a.append("has horn")
if self.grants_wishes:
a.append("grants wishes")
if self.swims_fast:
a.append("swims fast")
if self.sings_beautifully:
a.append("sings beautifully")
#return "This magical creature " + ", ".join(a) +"."
return "This magical creature " + ", ".join(a) + "."
def generate_magical_creature():
# TODO: Create and return a HybridCreature object
return HybridCreature()
if __name__ == "__main__":
creature = generate_magical_creature()
print(creature.describe_abilities())
Learning course: Python Coding Challenges
Problem Link: Create a Magical Creature Generator Practice Problem in Python Coding Challenges