Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python (retired) Inheritance Override Inherited Methods

Won't change to uppercase

Hey guys. Posted this same question in the early afternoon yesterday and never got an answer... Any insights as to why my Grrr!!! isn't coming back in uppercase?

sheep.py
from animal import Animal

class Sheep(Animal):
  pass
  sound = 'Grrr!!!'

  def __str__(self):
    self.sheep.noise = self.sound.upper()

2 Answers

cm21
cm21
150,854 Points

Hi Carina,

Instead of a str method, let's create a method named noise, and have it return the uppercase value of the instance's sound. That way, noise will be set to that value (the uppercase value of self.sound.)

from animal import Animal

class Sheep(Animal):
  pass
  sound = 'Grrr!!!'

  def noise(self):
    return self.sound.upper()

Hope this helps!

YES!!! Thank you! Was starting to go a bit bonkers. Haha