2022-10-18

Why one of the methods does not complete to execution?

class Dog:
    species = "Canis familiaris"
    
    
    def __init__(self, name, age, color):
        self.name = name
        self.age = age
        self.coat_color = color
        
# Instance method
    def description(self):
        return f"{self.name} is {self.age} years old"
    
    def __str__(self):
        return f"{self.name} is {self.age} years old"
    
# Another instance method

    def speak(self, sound):
        return f"{self.name} says {sound}"
    
#  Coat Color
    def coat_color(self, color):
        print(f"{self.name}'s coat is {self.color}.")

philo = Dog("Philo", 5, "brown")      # Instantiate

print(philo.coat_color)

## brown                     #  Response

Why is the second line print(f"{self.name}'s coat is {self.color}.") not getting executed?



No comments:

Post a Comment