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 trialChiroi Niehus
6,729 PointsI Am Having Trouble on Code Challenge: Double Task 3 of 3
I am having trouble figuring out whether it should be self or int that I multiply by 2. Also, I'm not sure where to put the two separate lines of code - inside the function, or in the class. Please help!
class Double(int):
def __new__(*args, **kwargs):
self = int.__new__(*args, **kwargs)
return self
doubled_value = self * 2
return doubled_value
1 Answer
Kamaren McCord
11,236 PointsIt looks like you want to put the code for the *double * inside of the new method. If you put it outside of this method the code will not be ran and thus will not return self * 2 when created.
self is an int so take self and multiply by 2, then return self.
also keep in mind that you cannot return code after a return has already been made. so you cannot use double return statements.
Ryan McGuire
3,758 PointsRyan McGuire
3,758 PointsThank you!