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 Dice Roller Compare and Contrast

Oliver White
Oliver White
5,948 Points

What is wrong with this ? OOP dice rolling

Hello

It is giving no preview and no useful error - no idea why this is not happy the code is the same as we generated in the lesson

songs.py
class Song:
    def __init__(self, artist, title, length):
        self.artist = artist
        self.title = title
        self.length = length

    def __int__(self):
        return self.value

    def __eq__(sef,other):
        return int(self) == other

    def __lt__(self,other):
        return int(self) < other

    def __gt_(self,other):
        return int(self) > other


    def __le__(self,other):
        return int(self) < other or int(self) == other 

    def __ge__(self,other):
        return int(self) > other or int(self) == other
Oliver White
Oliver White
5,948 Points

Not sure why the "or" is not showing up - if you highlight the row it is there in the code

also spotted the missing underscore after corrected and still not running def _gt(self,other): return int(self) > other

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

You're on the right track here Oliver White ! 🎉

After fixing that missing underscore that you mentioned in the __gt__ method, I found two small things.

  1. It's wanting the __int__ function to return the length, not the value

  2. There is also a typo in the __eq__ parameter, it currently says sef instead of self.

You're absolutely right in that error message is not helpful at all. I'll see if that's something that can be adjusted. Thanks for pointing that out!

Oliver White
Oliver White
5,948 Points

Thanks for this

Not sure how I missed such basic errors -- I get frustrate when all the feedback you get is "Bummer try again" -- does not give you much to help you break down the issue -- oh well - thanks so much -- hope not to make such basic mistakes again

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

No worries, when working in common IDE's they will normally point out small mistakes like this to you as you type. I still make mistakes like this all the time, don't worry at all, you're doing great!

The true issue here was the error message you were receiving for sure. That gave you no clues on why you weren't passing. I'm going to try my best to get that changed up for the next students but from what I understand it's quite the process.

I'm glad you made it through it! 👏💪