Thomas Ma15,199 Points
Change the return statement to return the integer times 2. For example, Double(5) would return a 10.
Please help me with this
class Double(): def __new__(*args,**kwargs): return int.__new__(*args,**kwargs)
Megan AmendolaTreehouse Teacher
In step one, your new class should take 'int' as a parent. You're missing 'int' in your code above.
class Double(int): pass
In step 2, it's asking you to pass in self and one other argument, let's call it num. Then you need to use int to convert it and return that value:
class Double(int): def __new__(self, num): return int(num)
Then in step 3, you need to modify the return so it now returns the newly converted int times 2:
class Double(int): def __new__(self, num): return int(num) * 2
The goal here is to use int() as a function call. Right now, you are calling int's
__new__ method and passing in values.
Brian Kiefer12,693 Points
Thank you. This makes much more sense than the other ones i looked at. I actually understand whats going on here.