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

Why do we not need to use int(other) in comparisons?

When we write:

return int(self) == other

I see this as comparing an instance of int to an instance of Die, which doesn't make sense. How is other automatically being converted to an int? Shouldn't it be:

return int(self) == int(other)

??

2 Answers

Using == is checking to make sure both are the same. If you say int(self) == other, that should already be checking that other is an int.

Ohhh, I think I misunderstood what the comparison was from the start - we ARE comparing a Die to an int

:)