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

Why do i keep getting an ´"AssertionError"?

This code works fine when i run it in my IDE, but when i run it here i keep getting an "AssertonError". Does anyone know why?

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 "{} eats {}.".format(self.name, self.food)

    def check_if_hungry(self):
        if  self.is_hungry:
            self.eat()

2 Answers

Steven Parker
Steven Parker
231,172 Points

Your IDE doesn't care if you follow the PEP8 best practices or not, but the challenge is being more picky than functionally necessary about the code formatting and doesn't like the extra space between "if" and "self.is_hungry:". Remove that space and you'll pass the challenge.

If you think that's too strict, or if you just think the error message needs to be more helpful, you might make a suggestion to the Support folks.

Steven Parker
Steven Parker
231,172 Points

Carl Dahllof — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!

Ok, thanks!