Welcome to the Treehouse Community
Looking to learn something new?
Ryan Sands4,543 Points
Not sure how to complete songs.py (Compare and Contrast) python O.O challenge... Please help!!
I am not sure how to complete this please help me! Thanks
class Song: def __init__(self, artist, title, length): self.artist = artist self.title = title self.length = length songs = self.artist, self.lenth, self.title def __eq__(songs, other): return int(songs) == other def __le__(songs, other): return int(songs) < other or int(songs) == other def __ge__(songs, other): return int(songs) > other or int(songs) == other
Robert Stefanic35,157 Points
Well, there are a couple of things here.
(1.) There's a typo in your init.
songs = self.artist, self.lenth, self.title" you have "length" spelled wrong.
(2.) You're trying to cast "
songs" into an integer, but "
songs" isn't the type of thing that can be cast as an integer.
int() takes a string and casts it to an integer, but "
songs" is a tuple. You can either extract the relevant values out of the tuple or you can rewrite the class so it separates the variables that you need.
If you get stuck again, then let me know, and I'll try and help you.