Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Basic Object-Oriented Python Welcome to OOP Adding to our Panda

Feeding Panda Problems

I've been on this for a while now, I have the code from the course open on my other screen and I have been referencing it. I've tried every modification I can think of and I cannot get this code to clear. Any help would be greatly appreciated, thanks!

panda.py
class Panda:
    species = 'Ailuropoda melanoleuca'
    food = 'bamboo'

    def __init__(self, name, age):
        self.is_hungry = True
        self.name = name
        self.age = age

    def eat(self):
        self.is_hungry = False
        return ("f'{name} eats {food}")

panda_one = Panda("Bao Bao", 20)

1 Answer

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi! Your return inside of eat has some mistakes. return ("f'{name} eats {food}")

First, you don't need the (): return "f'{name} eats {food}"

Second, your quotations should be around the text with the f on the outside: return f"'{name} eats {food}"

Then you also have an extra quotation: return f"{name} eats {food}"

You also don't need to create an instance. That is being tested for you in the backend :)

Thank you, Megan! I guess I'm still a little rusty on the new string format process in python.