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 trialmarcolamoon
16,915 PointsStuck on what to do!!
And, finally, double (multiply by two) the int that you created in new. Return the new, doubled value. For example, Double(5) would return a 10.
class Double(int):
pass
class Double(int):
def __new__(*args,**kwargs):
return int.__new__(*args,**kwargs)
return int.__new__(double)
4 Answers
Anibal Marquina
9,523 Pointsclass Double(int):
def __new__(*arg, **kwarg):
return 2 * int.__new__(*arg, **kwarg)
J llama
12,631 PointsI always enter something that is correct but it says "bummer" and gives me no details on my error code.. fitfo kenneth u bearded dragon
Cristian Romero
11,911 PointsI think the question was just confusing or at least it could of been worded much different for only adding 2 * after return.
Jan Durcak
12,662 Pointsclass Double(int):
def __new__(value,keyword):
self = int.__new__(value,keyword)
self *= 2
return self
print(Double(5))
Anibal Marquina
9,523 PointsAnibal Marquina
9,523 PointsHi there you almost got it.. just need to multiply your new instance and that's it
Alex Davis
35,050 PointsAlex Davis
35,050 PointsWhy are you able to pass with arg and not with args when all I see Kenneth use is args and kwargs
Håvard Hytten
6,239 PointsHåvard Hytten
6,239 PointsAlex Davis whatever follows the asteric doesnt really matter. It could even be var or vars. You can read more about *args and **kwargs in the following link; https://pythontips.com/2013/08/04/args-and-kwargs-in-python-explained/