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 Object-Oriented Python Advanced Objects Double

Stuck 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.

doubler.py
class Double(int):
    pass

class Double(int):
    def __new__(*args,**kwargs):
        return int.__new__(*args,**kwargs)
    return int.__new__(double)

4 Answers

Anibal Marquina
Anibal Marquina
9,523 Points
class Double(int):
    def __new__(*arg, **kwarg):
        return 2 * int.__new__(*arg, **kwarg)
Anibal Marquina
Anibal Marquina
9,523 Points

Hi there you almost got it.. just need to multiply your new instance and that's it

Why are you able to pass with arg and not with args when all I see Kenneth use is args and kwargs

HÃ¥vard Hytten
HÃ¥vard Hytten
6,239 Points

Alex 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/

J llama
J llama
12,631 Points

I 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
Cristian Romero
11,911 Points

I think the question was just confusing or at least it could of been worded much different for only adding 2 * after return.

Jan Durcak
Jan Durcak
12,662 Points
class Double(int):
    def __new__(value,keyword):
        self = int.__new__(value,keyword)
        self *=   2
        return self

print(Double(5))