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
Kevin Lewis
16,622 PointsOnly prints 'not equal' won't print 'equal'
when I run the if statement in the console it only prints 'not equal' even though car_one and car_two are equal
def __init__(self, model, year, make='Ford', gas=100):
# Instance Attributes
self.make = make
self.model = model
self.year = year
self.gas = gas
# instance attributes don't have
# to be passed in
self.is_moving = False
def __str__(self):
return f'{self.make} {self.model} {self.year}'
def __eg__(self, other):
return self.make == other.make and self.model == other.model
car_one = Car("Mustang", 1908)
car_two = Car("Mustang", 1908)
car_three = Car('Branco', 2024)
if car_one == car_two:
print('equal')
else:
print('not equal')
2 Answers
Kevin Lewis
16,622 Pointsnever mind I found the very dumb and obvious syntax error eq not eg
Steven Parker
243,656 PointsOne of Parker's Principles of Programming is "Typos and misspellings are the bane of tyros and gurus alike".
And congratulations on resolving your own issue. Good job!