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 Object-Oriented Python Advanced Objects Proper Properties

I'm completely stuck on this question, I've been following along just fine. I re-watched the previous video.

Please point me in a direction. Not sure how else to change my code based upon what was shown in the material thanks in advance.

rectangle.py
class Rectangle:
    def __init__(self, width, length):
        self.width = width
        self.length = length

    @property
    def area(self, area):
        return self.width * self.height

3 Answers

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

Two things:

  • there's no property called height in this class. I think you mean length
  • you're passing in an argument to area called area. You don't need that

These things are easier when you're using your own text editor/IDE and get real, more specific error messages as opposed to just "Bummer!"

class Rectangle: def init(self, width, length): self.width = width self.length = length

@property def area(self): return self.width * self.length

I changed it and also redid the tab/indent but I'm still stuck. Thank you.

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,735 Points

I put in your code with proper indentation and it worked:

class Rectangle: 
    def __init__(self, width, length): 
        self.width = width 
        self.length = length

    @property
    def area(self): 
        return self.width * self.length

For some reason when I copy pasted the dunders didn't appear. I am using init in the code.

Great thank you so much. It looks like after I changed the silly mistake of height vs. length my tabs/spacing was still off somehow. Really saved me! Thanks for the quick help.